diff options
author | Andrew Cady <d@jerkface.net> | 2016-04-10 01:01:22 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2016-04-10 01:01:22 -0400 |
commit | 35fcdaac9e340014110837ccb2f8de4a5f653980 (patch) | |
tree | 8675f325625d9933d735f77b18bcab237f9c4a0f | |
parent | ccb1065fe4281a778dff5ace295708fe534f5e8c (diff) |
successfully fetched real certificate
-rw-r--r-- | acme-certify.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/acme-certify.hs b/acme-certify.hs index 739d450..14c4b70 100644 --- a/acme-certify.hs +++ b/acme-certify.hs | |||
@@ -90,7 +90,8 @@ data CertifyOpts = CertifyOpts { | |||
90 | 90 | ||
91 | data UpdateOpts = UpdateOpts { | 91 | data UpdateOpts = UpdateOpts { |
92 | updateConfigFile :: Maybe FilePath, | 92 | updateConfigFile :: Maybe FilePath, |
93 | updateHosts :: [String] | 93 | updateHosts :: [String], |
94 | updateStaging :: Bool | ||
94 | } | 95 | } |
95 | 96 | ||
96 | instance Show HttpProvisioner where | 97 | instance Show HttpProvisioner where |
@@ -113,6 +114,12 @@ updateOpts = fmap Update $ | |||
113 | metavar "FILENAME" <> | 114 | metavar "FILENAME" <> |
114 | help "location of YAML configuration file")) | 115 | help "location of YAML configuration file")) |
115 | <*> many (argument str (metavar "HOSTS")) | 116 | <*> many (argument str (metavar "HOSTS")) |
117 | <*> switch | ||
118 | (long "staging" <> help | ||
119 | (unwords | ||
120 | [ "Use staging servers instead of live servers" | ||
121 | , "(generated certificates will not be trusted!)" | ||
122 | ])) | ||
116 | 123 | ||
117 | certifyOpts :: Parser Command | 124 | certifyOpts :: Parser Command |
118 | certifyOpts = fmap Certify $ | 125 | certifyOpts = fmap Certify $ |
@@ -172,7 +179,7 @@ runUpdate UpdateOpts { .. } = do | |||
172 | return $ flip map (HashMap.keys hostParts) $ \domain -> | 179 | return $ flip map (HashMap.keys hostParts) $ \domain -> |
173 | (unpack host, domainName' $ unpack domain, combineSubdomains domain hostParts) | 180 | (unpack host, domainName' $ unpack domain, combineSubdomains domain hostParts) |
174 | 181 | ||
175 | globalCertificateDir <- getHomeDirectory <&> (</> ".acme/test") | 182 | globalCertificateDir <- getHomeDirectory <&> (</> if updateStaging then ".acme/test-certs" else ".acme/certs") |
176 | createDirectoryIfMissing True globalCertificateDir | 183 | createDirectoryIfMissing True globalCertificateDir |
177 | 184 | ||
178 | Just keys <- getOrCreateKeys $ globalCertificateDir </> "rsa.key" | 185 | Just keys <- getOrCreateKeys $ globalCertificateDir </> "rsa.key" |
@@ -196,7 +203,7 @@ runUpdate UpdateOpts { .. } = do | |||
196 | forM_ wantedCertSpecs $ \spec -> do | 203 | forM_ wantedCertSpecs $ \spec -> do |
197 | 204 | ||
198 | let terms = defaultTerms | 205 | let terms = defaultTerms |
199 | directoryUrl = stagingDirectoryUrl | 206 | directoryUrl = if updateStaging then stagingDirectoryUrl else liveDirectoryUrl |
200 | email = emailAddress $ encodeUtf8 . pack $ "root@" ++ (domainToString . fst . head) (csDomains spec) | 207 | email = emailAddress $ encodeUtf8 . pack $ "root@" ++ (domainToString . fst . head) (csDomains spec) |
201 | print =<< fetchCertificate directoryUrl terms email issuerCert spec | 208 | print =<< fetchCertificate directoryUrl terms email issuerCert spec |
202 | 209 | ||