File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Tests/AsyncHTTPClientTests Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ class HTTPClientNIOTSTests: XCTestCase {
6363 _ = try httpClient. get ( url: " https://localhost: \( httpBin. port) /get " ) . wait ( )
6464 XCTFail ( " This should have failed " )
6565 } catch let error as HTTPClient . NWTLSError {
66- XCTAssertEqual ( error. status, errSSLHandshakeFail)
66+ XCTAssert ( error. status == errSSLHandshakeFail || error. status == errSSLBadCert,
67+ " unexpected NWTLSError with status \( error. status) " )
6768 } catch {
6869 XCTFail ( " Error should have been NWTLSError not \( type ( of: error) ) " )
6970 }
Original file line number Diff line number Diff line change @@ -915,7 +915,12 @@ class HTTPClientTests: XCTestCase {
915915 XCTFail ( " Unexpected error: \( error) " )
916916 continue
917917 }
918- XCTAssertEqual ( clientError. status, errSSLHandshakeFail)
918+ // We're speaking TLS to a plain text server. This will cause the handshake to fail but given
919+ // that the bytes "HTTP/1.1" aren't the start of a valid TLS packet, we can also get
920+ // errSSLPeerProtocolVersion because the first bytes contain the version.
921+ XCTAssert ( clientError. status == errSSLHandshakeFail ||
922+ clientError. status == errSSLPeerProtocolVersion,
923+ " unexpected NWTLSError with status \( clientError. status) " )
919924 #endif
920925 } else {
921926 guard let clientError = error as? NIOSSLError , case NIOSSLError . handshakeFailed = clientError else {
You can’t perform that action at this time.
0 commit comments