File tree 2 files changed +8
-2
lines changed
Tests/AsyncHTTPClientTests
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ class HTTPClientNIOTSTests: XCTestCase {
63
63
_ = try httpClient. get ( url: " https://localhost: \( httpBin. port) /get " ) . wait ( )
64
64
XCTFail ( " This should have failed " )
65
65
} 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) " )
67
68
} catch {
68
69
XCTFail ( " Error should have been NWTLSError not \( type ( of: error) ) " )
69
70
}
Original file line number Diff line number Diff line change @@ -915,7 +915,12 @@ class HTTPClientTests: XCTestCase {
915
915
XCTFail ( " Unexpected error: \( error) " )
916
916
continue
917
917
}
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) " )
919
924
#endif
920
925
} else {
921
926
guard let clientError = error as? NIOSSLError , case NIOSSLError . handshakeFailed = clientError else {
You can’t perform that action at this time.
0 commit comments