Skip to content

Commit

Permalink
only try and renew certs if they exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ProofOfKeags committed Dec 2, 2020
1 parent efdc93d commit 6d56528
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions agent/src/Daemon/SslRenew.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import Lib.Ssl
import Daemon.ZeroConf ( getStart9AgentHostname )
import Lib.Tor
import Control.Carrier.Lift
import System.Directory ( removePathForcibly
import System.Directory ( doesPathExist
, removePathForcibly
, renameDirectory
)
import Lib.SystemCtl
Expand Down Expand Up @@ -74,5 +75,9 @@ renewSslLeafCert ctx = do

doesSslNeedRenew :: FilePath -> IO Bool
doesSslNeedRenew cert = do
ec <- liftIO $ system [i|openssl x509 -checkend 2592000 -noout -in #{cert}|]
pure $ ec /= ExitSuccess
exists <- doesPathExist cert
if exists
then do
ec <- liftIO $ system [i|openssl x509 -checkend 2592000 -noout -in #{cert}|]
pure $ ec /= ExitSuccess
else pure False

0 comments on commit 6d56528

Please sign in to comment.