pkcs10

PKCS#10 library https://github.com/fcomb/pkcs10-hs#readme

Version on this page:0.2.0.0
LTS Haskell 8.1:0.2.0.0
Stackage Nightly 2017-02-19:0.2.0.0
Latest on Hackage:0.2.0.0
Apache-2.0 licensed and maintained by Timothy Klim

Module documentation for 0.2.0.0

PKCS#10 library

Build Status

Example

import           Crypto.Hash
import           Crypto.PubKey.RSA
import           Data.X509
import           Data.X509.PKCS10

main :: IO ()
main = do
  let rsaKeySize = 128
  let publicExponent = 3
  (pubKey, privKey) <- generate rsaKeySize publicExponent
  let subjectAttrs = makeX520Attributes [(X520CommonName, "node.fcomb.io"), (X520OrganizationName, "fcomb")]
  let extAttrs = PKCS9Attributes [PKCS9Attribute $ ExtBasicConstraints False Nothing, PKCS9Attribute $ ExtKeyUsage [KeyUsage_digitalSignature,KeyUsage_nonRepudiation,KeyUsage_keyEncipherment]]
  Right req <- generateCSR subjectAttrs extAttrs (KeyPairRSA pubKey privKey) SHA512
  putStrLn . show . toPEM $ req -- export in PEM format
  putStrLn . show $ verify (csrToSigned req) $ PubKeyRSA pubKey -- sign CSR before verifying
comments powered byDisqus