network-api-support-0.0.2: src/Network/Api/Support/Security.hs
module Network.Api.Support.Security (
checkDomainOnly
) where
import qualified Data.ByteString.Char8 as B8
import Data.Certificate.X509 (X509)
import Network.TLS (TLSCertificateUsage)
import Network.TLS.Extra (certificateVerifyDomain)
-- | A TLS validator that checks the domain only. Note that this means the validator
-- | will not check the cert chain, and can be used on systems where Data.Certificate.X509
-- | falls over as it does not have access to local root certs.
-- |
-- | ! Use with caution !
checkDomainOnly :: B8.ByteString -> [X509] -> IO TLSCertificateUsage
checkDomainOnly host' certs = return $ certificateVerifyDomain (B8.unpack host') certs