diff options
Diffstat (limited to 'acme.hs')
-rw-r--r-- | acme.hs | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -111,7 +111,7 @@ genKey privKeyFile = withOpenSSL $ do | |||
111 | 111 | ||
112 | genReq :: FilePath -> String -> IO String | 112 | genReq :: FilePath -> String -> IO String |
113 | genReq domainKeyFile domain = withOpenSSL $ do | 113 | genReq 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 | ||
123 | readKeys :: String -> IO Keys | 123 | readKeyFile :: FilePath -> IO (Maybe Keys) |
124 | readKeys privKeyFile = do | 124 | readKeyFile = 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 | ||
129 | data ChallengeRequest = ChallengeRequest { crUri :: String, crToken :: ByteString, crThumbToken :: ByteString } | 126 | data 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 | } |
248 | newtype Nonce = Nonce String | 245 | newtype Nonce = Nonce String |
249 | 246 | ||
250 | runTest :: ACME b -> IO b | ||
251 | runTest t = readKeys "rsa.key" >>= flip (runACME stagingDirectoryUrl) t | ||
252 | |||
253 | getDirectory :: WS.Session -> String -> IO (Maybe (Directory, Nonce)) | 247 | getDirectory :: WS.Session -> String -> IO (Maybe (Directory, Nonce)) |
254 | getDirectory sess url = do | 248 | getDirectory sess url = do |
255 | r <- WS.get sess url | 249 | r <- WS.get sess url |