summaryrefslogtreecommitdiff
path: root/acme.hs
diff options
context:
space:
mode:
Diffstat (limited to 'acme.hs')
-rw-r--r--acme.hs14
1 files changed, 4 insertions, 10 deletions
diff --git a/acme.hs b/acme.hs
index 8257390..69b0eb5 100644
--- a/acme.hs
+++ b/acme.hs
@@ -111,7 +111,7 @@ genKey privKeyFile = withOpenSSL $ do
111 111
112genReq :: FilePath -> String -> IO String 112genReq :: FilePath -> String -> IO String
113genReq domainKeyFile domain = withOpenSSL $ do 113genReq domainKeyFile domain = withOpenSSL $ do
114 (Keys priv pub) <- readKeys domainKeyFile 114 Just (Keys priv pub) <- readKeyFile domainKeyFile
115 Just dig <- getDigestByName "SHA256" 115 Just dig <- getDigestByName "SHA256"
116 req <- newX509Req 116 req <- newX509Req
117 setSubjectName req [("CN", domain)] 117 setSubjectName req [("CN", domain)]
@@ -120,11 +120,8 @@ genReq domainKeyFile domain = withOpenSSL $ do
120 signX509Req req priv (Just dig) 120 signX509Req req priv (Just dig)
121 writeX509ReqDER req 121 writeX509ReqDER req
122 122
123readKeys :: String -> IO Keys 123readKeyFile :: FilePath -> IO (Maybe Keys)
124readKeys privKeyFile = do 124readKeyFile = readFile >=> readKeys
125 priv <- readFile privKeyFile >>= flip readPrivateKey PwTTY
126 pub <- rsaCopyPublic $ fromMaybe (error "Error: failed to parse RSA key.") (toKeyPair priv :: Maybe RSAKeyPair)
127 return $ Keys priv pub
128 125
129data ChallengeRequest = ChallengeRequest { crUri :: String, crToken :: ByteString, crThumbToken :: ByteString } 126data ChallengeRequest = ChallengeRequest { crUri :: String, crToken :: ByteString, crThumbToken :: ByteString }
130 127
@@ -147,7 +144,7 @@ go CmdOpts{..} = do
147 doesDirectoryExist optDomain `otherwiseM` createDirectory domainDir 144 doesDirectoryExist optDomain `otherwiseM` createDirectory domainDir
148 doesFileExist domainKeyFile `otherwiseM` genKey domainKeyFile 145 doesFileExist domainKeyFile `otherwiseM` genKey domainKeyFile
149 146
150 keys <- readKeys privKeyFile 147 Just keys <- readKeyFile privKeyFile
151 148
152 doesFileExist domainCSRFile `otherwiseM` genReq domainKeyFile optDomain >>= writeFile domainCSRFile 149 doesFileExist domainCSRFile `otherwiseM` genReq domainKeyFile optDomain >>= writeFile domainCSRFile
153 150
@@ -247,9 +244,6 @@ data Directory = Directory {
247} 244}
248newtype Nonce = Nonce String 245newtype Nonce = Nonce String
249 246
250runTest :: ACME b -> IO b
251runTest t = readKeys "rsa.key" >>= flip (runACME stagingDirectoryUrl) t
252
253getDirectory :: WS.Session -> String -> IO (Maybe (Directory, Nonce)) 247getDirectory :: WS.Session -> String -> IO (Maybe (Directory, Nonce))
254getDirectory sess url = do 248getDirectory sess url = do
255 r <- WS.get sess url 249 r <- WS.get sess url