https://github.com/scrive/pkcs10-hs
Haskell PKCS #10 library
https://github.com/scrive/pkcs10-hs
Last synced: 8 months ago
JSON representation
Haskell PKCS #10 library
- Host: GitHub
- URL: https://github.com/scrive/pkcs10-hs
- Owner: scrive
- License: other
- Created: 2024-03-06T16:53:49.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-07T14:30:58.000Z (over 2 years ago)
- Last Synced: 2025-02-24T08:16:11.978Z (over 1 year ago)
- Language: Haskell
- Homepage:
- Size: 61.5 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
PKCS#10 library
=========
[](https://travis-ci.org/fcomb/pkcs10-hs)
### Example
```haskell
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
```