newCrt :: [String] -> IO B.ByteString
newCrt domains = do
  let rsaKeySize = 256 :: Int
  let publicExponent = 0x10001 :: Integer
  (pubKey, privKey) <- generate rsaKeySize publicExponent
  let subjectAttrs =
        makeX520Attributes
          [(X520CommonName, head domains), (X520OrganizationName, head domains)]
  Right req <-
    generateCSR
      subjectAttrs
      (PKCS9Attributes
         [PKCS9Attribute . ExtSubjectAltName $ map AltNameDNS domains])
      (KeyPairRSA pubKey privKey)
      SHA512
  putStrLn $ B.unpack $ pemWriteBS $ toPEM req
  return $ toDER req
newCrt :: [String] -> IO B.ByteString
newCrt domains = do
  let rsaKeySize = 256 :: Int
  let publicExponent = 0x10001 :: Integer
  (pubKey, privKey) <- generate rsaKeySize publicExponent
  let subjectAttrs =
        makeX520Attributes
          [(X520CommonName, head domains), (X520OrganizationName, head domains)]
  Right req <-
    generateCSR
      subjectAttrs
      (PKCS9Attributes
         [PKCS9Attribute . ExtSubjectAltName $ map AltNameDNS domains])
      (KeyPairRSA pubKey privKey)
      SHA512
  putStrLn $ B.unpack $ pemWriteBS $ toPEM req
  return $ toDER req
newCrt domains = do
  let rsaKeySize = 256 :: Int
  let publicExponent = 0x10001 :: Integer
  (pubKey, privKey) <- generate rsaKeySize publicExponent
  let subjectAttrs =
        makeX520Attributes
          [(X520CommonName, head domains), (X520OrganizationName, head domains)]
  Right req <-
    generateCSR
      subjectAttrs
      (PKCS9Attributes
         [PKCS9Attribute . ExtSubjectAltName $ map AltNameDNS domains])
      (KeyPairRSA pubKey privKey)
      SHA512
  putStrLn $ B.unpack $ pemWriteBS $ toPEM req
  return $ toDER req