summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-01-22 18:37:03 -0500
committerAndrew Cady <d@jerkface.net>2016-01-22 18:37:03 -0500
commitf599e81c7a5625a79d56a14d03e6e36e12dbebd7 (patch)
tree39551bb580e4fd1a0a2b791dec0ec32a45c34ef3 /src
parent15d6572b9fa0ff6b0105eaa26583f496b18f78b4 (diff)
move key reading function into exported library
Diffstat (limited to 'src')
-rw-r--r--src/Network/ACME.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Network/ACME.hs b/src/Network/ACME.hs
index f8135e6..2481163 100644
--- a/src/Network/ACME.hs
+++ b/src/Network/ACME.hs
@@ -6,6 +6,7 @@
6 6
7module Network.ACME ( 7module Network.ACME (
8 Keys(..), 8 Keys(..),
9 readKeys,
9 thumbprint, 10 thumbprint,
10 JWK(..), 11 JWK(..),
11 toStrict, 12 toStrict,
@@ -51,7 +52,13 @@ import OpenSSL.PEM
51import OpenSSL.RSA 52import OpenSSL.RSA
52import OpenSSL.X509.Request 53import OpenSSL.X509.Request
53 54
54data Keys = Keys SomeKeyPair RSAPubKey 55data Keys = Keys RSAKeyPair RSAPubKey
56readKeys :: String -> IO (Maybe Keys)
57readKeys privKeyData = do
58 keypair :: SomeKeyPair <- readPrivateKey privKeyData PwTTY
59 let (priv :: Maybe RSAKeyPair) = toKeyPair keypair
60 pub :: Maybe RSAPubKey <- maybe (return Nothing) (fmap Just . rsaCopyPublic) priv
61 return $ Keys <$> priv <*> pub
55 62
56-------------------------------------------------------------------------------- 63--------------------------------------------------------------------------------
57-- | Sign return a payload with a nonce-protected header. 64-- | Sign return a payload with a nonce-protected header.