Skip to content

Commit e36f741

Browse files
authored
Merge pull request snoyberg#550 from marinelli/tls-2
Fix running tests with badssl.com
2 parents c982be2 + a8f05ac commit e36f741

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

http-client-tls/http-client-tls.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ test-suite spec
4646
, http-client-tls
4747
, http-types
4848
, crypton-connection
49+
, data-default
50+
, tls
4951

5052
benchmark benchmark
5153
main-is: Bench.hs

http-client-tls/test/Spec.hs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE OverloadedStrings #-}
23
import Test.Hspec
34
import Network.Connection
45
import Network.HTTP.Client
5-
import Network.HTTP.Client.TLS
6+
import Network.HTTP.Client.TLS hiding (tlsManagerSettings)
67
import Network.HTTP.Types
78
import Control.Monad (join)
9+
import Data.Default
10+
import qualified Network.TLS as TLS
811

912
main :: IO ()
1013
main = hspec $ do
14+
let tlsSettings = def
15+
-- Since the release of v2.0.0 of the `tls` package , the default value of
16+
-- the `supportedExtendedMainSecret` parameter `is `RequireEMS`, this means
17+
-- that all the connections to a server not supporting TLS1.2+EMS will fail.
18+
-- The badssl.com service does not yet support TLS1.2+EMS connections, so
19+
-- let's switch to the value `AllowEMS`, ie: TLS1.2 conenctions without EMS.
20+
#if MIN_VERSION_crypton_connection(0,4,0)
21+
{settingClientSupported = def {TLS.supportedExtendedMainSecret = TLS.AllowEMS}}
22+
#endif
23+
24+
let tlsManagerSettings = mkManagerSettings tlsSettings Nothing
25+
1126
it "make a TLS connection" $ do
1227
manager <- newManager tlsManagerSettings
1328
withResponse "https://httpbin.org/status/418" manager $ \res ->
@@ -52,13 +67,13 @@ main = hspec $ do
5267
-- https://github.com/snoyberg/http-client/issues/289
5368
it "accepts TLS settings" $ do
5469
let
55-
tlsSettings = TLSSettingsSimple
70+
tlsSettings' = tlsSettings
5671
{ settingDisableCertificateValidation = True
5772
, settingDisableSession = False
5873
, settingUseServerName = False
5974
}
6075
socketSettings = Nothing
61-
managerSettings = mkManagerSettings tlsSettings socketSettings
76+
managerSettings = mkManagerSettings tlsSettings' socketSettings
6277
manager <- newTlsManagerWith managerSettings
6378
let url = "https://wrong.host.badssl.com"
6479
request <- parseRequest url

0 commit comments

Comments
 (0)