summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Openssl.hs
blob: 0cb7c9c216943419b2527d8b8390cbe25d5f2c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
-- | Maintainer: FĂ©lix Sipma <felix+propellor@gueux.org>

module Propellor.Property.Openssl where

import Propellor.Base
import qualified Propellor.Property.Apt as Apt
import qualified Propellor.Property.File as File
import Utility.SafeCommand

installed :: Property DebianLike
installed = Apt.installed ["openssl"]

dhparamsLength :: Int
dhparamsLength = 2048

dhparams :: FilePath
dhparams = "/etc/ssl/private/dhparams.pem"

safeDhparams :: Property DebianLike
safeDhparams = propertyList "safe dhparams" $ props
	& File.dirExists (takeDirectory dhparams)
	& installed
	& check (not <$> doesFileExist dhparams) (createDhparams dhparams dhparamsLength)

createDhparams :: FilePath -> Int -> Property UnixLike
createDhparams f l = property ("generate new dhparams: " ++ f) $ liftIO $ withUmask 0o0177 $ withFile f WriteMode $ \h ->
	cmdResult <$> boolSystem' "openssl" [Param "dhparam", Param (show l)] (\p -> p { std_out = UseHandle h })