From 35fcdaac9e340014110837ccb2f8de4a5f653980 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 10 Apr 2016 01:01:22 -0400 Subject: successfully fetched real certificate --- acme-certify.hs | 13 ++++++++++--- 1 file 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 { data UpdateOpts = UpdateOpts { updateConfigFile :: Maybe FilePath, - updateHosts :: [String] + updateHosts :: [String], + updateStaging :: Bool } instance Show HttpProvisioner where @@ -113,6 +114,12 @@ updateOpts = fmap Update $ metavar "FILENAME" <> help "location of YAML configuration file")) <*> many (argument str (metavar "HOSTS")) + <*> switch + (long "staging" <> help + (unwords + [ "Use staging servers instead of live servers" + , "(generated certificates will not be trusted!)" + ])) certifyOpts :: Parser Command certifyOpts = fmap Certify $ @@ -172,7 +179,7 @@ runUpdate UpdateOpts { .. } = do return $ flip map (HashMap.keys hostParts) $ \domain -> (unpack host, domainName' $ unpack domain, combineSubdomains domain hostParts) - globalCertificateDir <- getHomeDirectory <&> ( ".acme/test") + globalCertificateDir <- getHomeDirectory <&> ( if updateStaging then ".acme/test-certs" else ".acme/certs") createDirectoryIfMissing True globalCertificateDir Just keys <- getOrCreateKeys $ globalCertificateDir "rsa.key" @@ -196,7 +203,7 @@ runUpdate UpdateOpts { .. } = do forM_ wantedCertSpecs $ \spec -> do let terms = defaultTerms - directoryUrl = stagingDirectoryUrl + directoryUrl = if updateStaging then stagingDirectoryUrl else liveDirectoryUrl email = emailAddress $ encodeUtf8 . pack $ "root@" ++ (domainToString . fst . head) (csDomains spec) print =<< fetchCertificate directoryUrl terms email issuerCert spec -- cgit v1.2.3