summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2016-01-20 07:10:21 -0500
committerAndrew Cady <d@jerkface.net>2016-01-20 07:10:21 -0500
commitc703ebce4814d71ab7ebfc074d19b8d2c4c4bbdf (patch)
treea6ff4729922ab3f2b01f189280c225346ff995d4
parentec64081c83707657ee1aa641d193d346f292e744 (diff)
Fetch nonce instead of hard-coding it
-rw-r--r--acme.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/acme.hs b/acme.hs
index 2f8138c..f8e92e3 100644
--- a/acme.hs
+++ b/acme.hs
@@ -17,6 +17,7 @@ import qualified Data.ByteString.Lazy as LB
17import qualified Data.ByteString.Base64.URL as Base64 17import qualified Data.ByteString.Base64.URL as Base64
18import Data.Digest.Pure.SHA (bytestringDigest, sha256) 18import Data.Digest.Pure.SHA (bytestringDigest, sha256)
19import Data.Text.Encoding (decodeUtf8) 19import Data.Text.Encoding (decodeUtf8)
20import qualified Data.Text as T
20import OpenSSL.EVP.PKey 21import OpenSSL.EVP.PKey
21import OpenSSL.PEM (readPublicKey) 22import OpenSSL.PEM (readPublicKey)
22import OpenSSL.RSA 23import 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