diff options
author | Andrew Cady <d@jerkface.net> | 2016-01-20 07:10:21 -0500 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-01-20 07:10:21 -0500 |
commit | c703ebce4814d71ab7ebfc074d19b8d2c4c4bbdf (patch) | |
tree | a6ff4729922ab3f2b01f189280c225346ff995d4 | |
parent | ec64081c83707657ee1aa641d193d346f292e744 (diff) |
Fetch nonce instead of hard-coding it
-rw-r--r-- | acme.hs | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -17,6 +17,7 @@ import qualified Data.ByteString.Lazy as LB | |||
17 | import qualified Data.ByteString.Base64.URL as Base64 | 17 | import qualified Data.ByteString.Base64.URL as Base64 |
18 | import Data.Digest.Pure.SHA (bytestringDigest, sha256) | 18 | import Data.Digest.Pure.SHA (bytestringDigest, sha256) |
19 | import Data.Text.Encoding (decodeUtf8) | 19 | import Data.Text.Encoding (decodeUtf8) |
20 | import qualified Data.Text as T | ||
20 | import OpenSSL.EVP.PKey | 21 | import OpenSSL.EVP.PKey |
21 | import OpenSSL.PEM (readPublicKey) | 22 | import OpenSSL.PEM (readPublicKey) |
22 | import OpenSSL.RSA | 23 | import OpenSSL.RSA |
@@ -31,6 +32,9 @@ main = do | |||
31 | case toPublicKey userKey_ of | 32 | case toPublicKey userKey_ of |
32 | Nothing -> error "Not a public RSA key." | 33 | Nothing -> error "Not a public RSA key." |
33 | Just (userKey :: RSAPubKey) -> do | 34 | Just (userKey :: RSAPubKey) -> do |
35 | |||
36 | nonce_ <- view (responseHeader "Replay-Nonce" . to (T.unpack . decodeUtf8)) <$> get "https://acme-v01.api.letsencrypt.org/directory" | ||
37 | |||
34 | let protected = b64 (header userKey nonce_) | 38 | let protected = b64 (header userKey nonce_) |
35 | 39 | ||
36 | -- Create user account | 40 | -- Create user account |
@@ -65,9 +69,6 @@ main = do | |||
65 | domain :: String | 69 | domain :: String |
66 | domain = "aaa.reesd.com" | 70 | domain = "aaa.reesd.com" |
67 | 71 | ||
68 | nonce_ :: String | ||
69 | nonce_ = "ckYlMQ7BflfUb7HmxipdSpnkFle83-8lUkn50U-X97Q" | ||
70 | |||
71 | terms :: String | 72 | terms :: String |
72 | terms = "https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf" | 73 | terms = "https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf" |
73 | 74 | ||