From 34775b4128de2801e4d127064f012501ca18d208 Mon Sep 17 00:00:00 2001 From: Cédric Couralet Date: Mon, 13 Apr 2020 23:58:42 +0200 Subject: Add an option to disable certificate validation (#6156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds the option `--no-check-certificate`, which disables certificate checking when resources are fetched by HTTP. Co-authored-by: Cécile Chemin Co-authored-by: Juliette Fourcot --- src/Text/Pandoc/Class/PandocIO.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Class/PandocIO.hs') diff --git a/src/Text/Pandoc/Class/PandocIO.hs b/src/Text/Pandoc/Class/PandocIO.hs index 1cbfd680e..ee6a041ba 100644 --- a/src/Text/Pandoc/Class/PandocIO.hs +++ b/src/Text/Pandoc/Class/PandocIO.hs @@ -54,7 +54,8 @@ import Network.HTTP.Client (httpLbs, responseBody, responseHeaders, Request(port, host, requestHeaders), parseRequest, newManager) import Network.HTTP.Client.Internal (addProxy) -import Network.HTTP.Client.TLS (tlsManagerSettings) +import Network.HTTP.Client.TLS (mkManagerSettings) +import Network.Connection (TLSSettings (..)) import Network.HTTP.Types.Header ( hContentType ) import Network.Socket (withSocketsDo) import Network.URI ( unEscapeString ) @@ -139,6 +140,7 @@ instance PandocMonad PandocIO where | otherwise = do let toReqHeader (n, v) = (CI.mk (UTF8.fromText n), UTF8.fromText v) customHeaders <- map toReqHeader <$> getsCommonState stRequestHeaders + disableCertificateValidation <- getsCommonState stNoCheckCertificate report $ Fetching u res <- liftIO $ E.try $ withSocketsDo $ do let parseReq = parseRequest @@ -149,7 +151,7 @@ instance PandocMonad PandocIO where return (addProxy (host r) (port r) x) req <- parseReq (T.unpack u) >>= addProxy' let req' = req{requestHeaders = customHeaders ++ requestHeaders req} - resp <- newManager tlsManagerSettings >>= httpLbs req' + resp <- newManager (mkManagerSettings (TLSSettingsSimple disableCertificateValidation False False) Nothing) >>= httpLbs req' return (B.concat $ toChunks $ responseBody resp, UTF8.toText `fmap` lookup hContentType (responseHeaders resp)) -- cgit v1.2.3