Add unit tests for WKWebView.serverTrust
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 21:46:46 +0000 (21:46 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Apr 2019 21:46:46 +0000 (21:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197202

Source/ThirdParty/libwebrtc:

Reviewed by Youenn Fablet.

* libwebrtc.xcodeproj/project.pbxproj:
Move boringssl files from libwebrtc target to boringssl target.
Also, add pkcs7 files to boringssl static library.

Tools:

Reviewed by Youenn Fablet

* TestWebKitAPI/TCPServer.cpp:
(TestWebKitAPI::deleter<BIO>::operator()):
(TestWebKitAPI::deleter<SSL>::operator()):
(TestWebKitAPI::deleter<X509>::operator()):
(TestWebKitAPI::deleter<SSL_CTX>::operator()):
(TestWebKitAPI::deleter<EVP_PKEY>::operator()):
(TestWebKitAPI::TCPServer::TCPServer):
(TestWebKitAPI::TCPServer::listenForConnections):
* TestWebKitAPI/TCPServer.h:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(TestWebKitAPI::TEST):
(verifyCertificateAndPublicKey):
(-[ServerTrustDelegate webView:didFinishNavigation:]):
(-[ServerTrustDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]):
* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(TestWebKitAPI::downloadAtRate):
* TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm:
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244568 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/libwebrtc.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/TCPServer.cpp
Tools/TestWebKitAPI/TCPServer.h
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm

index 4389505..bd2fd52 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-23  Alex Christensen  <achristensen@webkit.org>
+
+        Add unit tests for WKWebView.serverTrust
+        https://bugs.webkit.org/show_bug.cgi?id=197202
+
+        Reviewed by Youenn Fablet.
+
+        * libwebrtc.xcodeproj/project.pbxproj:
+        Move boringssl files from libwebrtc target to boringssl target.
+        Also, add pkcs7 files to boringssl static library.
+
 2019-04-08  Justin Fan  <justin_fan@apple.com>
 
         [Web GPU] Fix Web GPU experimental feature on iOS
index f1e0298..58e1da5 100644 (file)
                419C843D1FE24E800040C30F /* temporal_layers.h in Headers */ = {isa = PBXBuildFile; fileRef = 419C84331FE24E800040C30F /* temporal_layers.h */; };
                419C843E1FE250490040C30F /* ssladapter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 413A22251FE18DCD00373E99 /* ssladapter.cc */; };
                419C843F1FE250B90040C30F /* opensslstreamadapter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 413A218D1FE18D8300373E99 /* opensslstreamadapter.cc */; };
-               419C845D1FE255FA0040C30F /* tls13_server.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84401FE255EF0040C30F /* tls13_server.cc */; };
-               419C845E1FE255FA0040C30F /* ssl_aead_ctx.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84411FE255EF0040C30F /* ssl_aead_ctx.cc */; };
-               419C845F1FE255FA0040C30F /* ssl_session.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84421FE255EF0040C30F /* ssl_session.cc */; };
-               419C84601FE255FA0040C30F /* ssl_buffer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84431FE255F00040C30F /* ssl_buffer.cc */; };
-               419C84611FE255FA0040C30F /* ssl_stat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84441FE255F00040C30F /* ssl_stat.cc */; };
-               419C84621FE255FA0040C30F /* ssl_transcript.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84451FE255F10040C30F /* ssl_transcript.cc */; };
-               419C84631FE255FA0040C30F /* tls13_enc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84461FE255F10040C30F /* tls13_enc.cc */; };
-               419C84641FE255FA0040C30F /* ssl_x509.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84471FE255F10040C30F /* ssl_x509.cc */; };
-               419C84651FE255FA0040C30F /* ssl_cipher.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84481FE255F10040C30F /* ssl_cipher.cc */; };
-               419C84661FE255FA0040C30F /* tls_record.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84491FE255F20040C30F /* tls_record.cc */; };
-               419C84671FE255FA0040C30F /* tls13_client.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844A1FE255F20040C30F /* tls13_client.cc */; };
-               419C84681FE255FA0040C30F /* tls13_both.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844B1FE255F30040C30F /* tls13_both.cc */; };
-               419C84691FE255FA0040C30F /* handshake.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844C1FE255F30040C30F /* handshake.cc */; };
-               419C846B1FE255FA0040C30F /* tls_method.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844E1FE255F40040C30F /* tls_method.cc */; };
-               419C846C1FE255FA0040C30F /* ssl_privkey.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844F1FE255F40040C30F /* ssl_privkey.cc */; };
-               419C846D1FE255FA0040C30F /* t1_enc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84501FE255F40040C30F /* t1_enc.cc */; };
-               419C846E1FE255FA0040C30F /* ssl_versions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84511FE255F50040C30F /* ssl_versions.cc */; };
-               419C846F1FE255FA0040C30F /* bio_ssl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84521FE255F50040C30F /* bio_ssl.cc */; };
-               419C84701FE255FA0040C30F /* s3_both.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84531FE255F50040C30F /* s3_both.cc */; };
-               419C84721FE255FA0040C30F /* ssl_file.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84551FE255F60040C30F /* ssl_file.cc */; };
-               419C84731FE255FA0040C30F /* s3_pkt.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84561FE255F70040C30F /* s3_pkt.cc */; };
-               419C84741FE255FA0040C30F /* ssl_asn1.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84571FE255F70040C30F /* ssl_asn1.cc */; };
-               419C84751FE255FA0040C30F /* ssl_cert.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84581FE255F70040C30F /* ssl_cert.cc */; };
-               419C84761FE255FA0040C30F /* ssl_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84591FE255F80040C30F /* ssl_lib.cc */; };
-               419C84771FE255FA0040C30F /* s3_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C845A1FE255F80040C30F /* s3_lib.cc */; };
-               419C84781FE255FA0040C30F /* ssl_key_share.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C845B1FE255F90040C30F /* ssl_key_share.cc */; };
-               419C84791FE255FA0040C30F /* t1_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C845C1FE255F90040C30F /* t1_lib.cc */; };
-               419C84871FE2574D0040C30F /* d1_srtp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C847E1FE257490040C30F /* d1_srtp.cc */; };
-               419C84881FE2574D0040C30F /* dtls_method.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C847F1FE257490040C30F /* dtls_method.cc */; };
-               419C84891FE2574D0040C30F /* handshake_client.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84801FE2574A0040C30F /* handshake_client.cc */; };
-               419C848A1FE2574D0040C30F /* dtls_record.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84811FE2574A0040C30F /* dtls_record.cc */; };
-               419C848B1FE2574D0040C30F /* handshake_server.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84821FE2574A0040C30F /* handshake_server.cc */; };
-               419C848C1FE2574D0040C30F /* d1_both.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84831FE2574B0040C30F /* d1_both.cc */; };
-               419C848D1FE2574D0040C30F /* d1_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84841FE2574B0040C30F /* d1_lib.cc */; };
-               419C848F1FE2574D0040C30F /* d1_pkt.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84861FE2574C0040C30F /* d1_pkt.cc */; };
-               419C84921FE2591F0040C30F /* err_data.c in Sources */ = {isa = PBXBuildFile; fileRef = 419C84911FE2591E0040C30F /* err_data.c */; };
                419C84AA1FE303DE0040C30F /* h264.h in Headers */ = {isa = PBXBuildFile; fileRef = 419C84A81FE303DD0040C30F /* h264.h */; };
                419C84AB1FE303DE0040C30F /* h264_globals.h in Headers */ = {isa = PBXBuildFile; fileRef = 419C84A91FE303DE0040C30F /* h264_globals.h */; };
                419C84BC1FE319440040C30F /* audio_encoder_ilbc_config.h in Headers */ = {isa = PBXBuildFile; fileRef = 419C84B71FE319430040C30F /* audio_encoder_ilbc_config.h */; };
                5CDD905E1E43D11200621E92 /* bitrate_controller_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CDD90531E43D11200621E92 /* bitrate_controller_impl.h */; };
                5CDD90611E43D11200621E92 /* send_side_bandwidth_estimation.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5CDD905B1E43D11200621E92 /* send_side_bandwidth_estimation.cc */; };
                5CDD90621E43D11200621E92 /* send_side_bandwidth_estimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CDD905C1E43D11200621E92 /* send_side_bandwidth_estimation.h */; };
+               5CFACF33226E96BD0056C7D0 /* ssl_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84591FE255F80040C30F /* ssl_lib.cc */; };
+               5CFACF34226E96E60056C7D0 /* ssl_session.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84421FE255EF0040C30F /* ssl_session.cc */; };
+               5CFACF35226E96ED0056C7D0 /* bio_ssl.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84521FE255F50040C30F /* bio_ssl.cc */; };
+               5CFACF36226E96F20056C7D0 /* d1_both.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84831FE2574B0040C30F /* d1_both.cc */; };
+               5CFACF37226E96F70056C7D0 /* d1_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84841FE2574B0040C30F /* d1_lib.cc */; };
+               5CFACF38226E96FB0056C7D0 /* d1_pkt.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84861FE2574C0040C30F /* d1_pkt.cc */; };
+               5CFACF39226E96FE0056C7D0 /* d1_srtp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C847E1FE257490040C30F /* d1_srtp.cc */; };
+               5CFACF3A226E97050056C7D0 /* dtls_method.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C847F1FE257490040C30F /* dtls_method.cc */; };
+               5CFACF3B226E97080056C7D0 /* dtls_record.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84811FE2574A0040C30F /* dtls_record.cc */; };
+               5CFACF3C226E970C0056C7D0 /* handshake.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844C1FE255F30040C30F /* handshake.cc */; };
+               5CFACF3D226E970F0056C7D0 /* handshake_client.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84801FE2574A0040C30F /* handshake_client.cc */; };
+               5CFACF3E226E97120056C7D0 /* handshake_server.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84821FE2574A0040C30F /* handshake_server.cc */; };
+               5CFACF3F226E97180056C7D0 /* s3_both.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84531FE255F50040C30F /* s3_both.cc */; };
+               5CFACF40226E971C0056C7D0 /* s3_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C845A1FE255F80040C30F /* s3_lib.cc */; };
+               5CFACF41226E971F0056C7D0 /* s3_pkt.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84561FE255F70040C30F /* s3_pkt.cc */; };
+               5CFACF43226E97350056C7D0 /* ssl_aead_ctx.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84411FE255EF0040C30F /* ssl_aead_ctx.cc */; };
+               5CFACF44226E97390056C7D0 /* ssl_asn1.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84571FE255F70040C30F /* ssl_asn1.cc */; };
+               5CFACF45226E973C0056C7D0 /* ssl_buffer.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84431FE255F00040C30F /* ssl_buffer.cc */; };
+               5CFACF46226E97400056C7D0 /* ssl_cert.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84581FE255F70040C30F /* ssl_cert.cc */; };
+               5CFACF47226E975D0056C7D0 /* ssl_cipher.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84481FE255F10040C30F /* ssl_cipher.cc */; };
+               5CFACF48226E97610056C7D0 /* ssl_file.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84551FE255F60040C30F /* ssl_file.cc */; };
+               5CFACF49226E97650056C7D0 /* ssl_key_share.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C845B1FE255F90040C30F /* ssl_key_share.cc */; };
+               5CFACF4A226E976B0056C7D0 /* ssl_privkey.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844F1FE255F40040C30F /* ssl_privkey.cc */; };
+               5CFACF4B226E97710056C7D0 /* ssl_stat.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84441FE255F00040C30F /* ssl_stat.cc */; };
+               5CFACF4D226E97780056C7D0 /* ssl_transcript.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84451FE255F10040C30F /* ssl_transcript.cc */; };
+               5CFACF4E226E977D0056C7D0 /* ssl_versions.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84511FE255F50040C30F /* ssl_versions.cc */; };
+               5CFACF4F226E977F0056C7D0 /* ssl_x509.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84471FE255F10040C30F /* ssl_x509.cc */; };
+               5CFACF50226E97830056C7D0 /* t1_enc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84501FE255F40040C30F /* t1_enc.cc */; };
+               5CFACF51226E97860056C7D0 /* t1_lib.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C845C1FE255F90040C30F /* t1_lib.cc */; };
+               5CFACF52226E978A0056C7D0 /* tls13_both.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844B1FE255F30040C30F /* tls13_both.cc */; };
+               5CFACF53226E978D0056C7D0 /* tls13_client.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844A1FE255F20040C30F /* tls13_client.cc */; };
+               5CFACF54226E97910056C7D0 /* tls13_enc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84461FE255F10040C30F /* tls13_enc.cc */; };
+               5CFACF55226E97950056C7D0 /* tls13_server.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84401FE255EF0040C30F /* tls13_server.cc */; };
+               5CFACF56226E97980056C7D0 /* tls_method.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C844E1FE255F40040C30F /* tls_method.cc */; };
+               5CFACF57226E979C0056C7D0 /* tls_record.cc in Sources */ = {isa = PBXBuildFile; fileRef = 419C84491FE255F20040C30F /* tls_record.cc */; };
+               5CFACF58226E97CD0056C7D0 /* err_data.c in Sources */ = {isa = PBXBuildFile; fileRef = 419C84911FE2591E0040C30F /* err_data.c */; };
+               5CFACF5E226E9A1E0056C7D0 /* pkcs7_x509.c in Sources */ = {isa = PBXBuildFile; fileRef = 5CFACF5A226E9A1A0056C7D0 /* pkcs7_x509.c */; };
+               5CFACF5F226E9A1E0056C7D0 /* pkcs7.c in Sources */ = {isa = PBXBuildFile; fileRef = 5CFACF5B226E9A1A0056C7D0 /* pkcs7.c */; };
                5CFD537C1E4BA4F500482908 /* audio_device_ios.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CFD53751E4BA4F500482908 /* audio_device_ios.h */; };
                5CFD53801E4BA4F500482908 /* audio_session_observer.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CFD53791E4BA4F500482908 /* audio_session_observer.h */; };
                5CFD53811E4BA4F500482908 /* voice_processing_audio_unit.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CFD537A1E4BA4F500482908 /* voice_processing_audio_unit.h */; };
                5CDD90AB1E43D52900621E92 /* aes_icm_ossl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = aes_icm_ossl.c; path = cipher/aes_icm_ossl.c; sourceTree = "<group>"; };
                5CDD90AC1E43D52900621E92 /* cipher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cipher.c; path = cipher/cipher.c; sourceTree = "<group>"; };
                5CDD90AD1E43D52900621E92 /* null_cipher.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = null_cipher.c; path = cipher/null_cipher.c; sourceTree = "<group>"; };
+               5CFACF5A226E9A1A0056C7D0 /* pkcs7_x509.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pkcs7_x509.c; path = pkcs7/pkcs7_x509.c; sourceTree = "<group>"; };
+               5CFACF5B226E9A1A0056C7D0 /* pkcs7.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pkcs7.c; path = pkcs7/pkcs7.c; sourceTree = "<group>"; };
                5CFD53751E4BA4F500482908 /* audio_device_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_device_ios.h; sourceTree = "<group>"; };
                5CFD53761E4BA4F500482908 /* audio_device_ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = audio_device_ios.mm; sourceTree = "<group>"; };
                5CFD53791E4BA4F500482908 /* audio_session_observer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio_session_observer.h; sourceTree = "<group>"; };
                                5C4B44521E42A61A002651C8 /* lhash */,
                                5C4B44571E42A645002651C8 /* obj */,
                                5C4B44581E42A64B002651C8 /* pem */,
+                               5CFACF59226E99F20056C7D0 /* pkcs7 */,
                                5C4B445A1E42A65A002651C8 /* pkcs8 */,
                                5C4B445B1E42A664002651C8 /* poly1305 */,
                                41A391C11EFC465600C4516A /* pool */,
                        name = math;
                        sourceTree = "<group>";
                };
+               5CFACF59226E99F20056C7D0 /* pkcs7 */ = {
+                       isa = PBXGroup;
+                       children = (
+                               5CFACF5B226E9A1A0056C7D0 /* pkcs7.c */,
+                               5CFACF5A226E9A1A0056C7D0 /* pkcs7_x509.c */,
+                       );
+                       name = pkcs7;
+                       sourceTree = "<group>";
+               };
                5CFD53611E4BA36100482908 /* ios */ = {
                        isa = PBXGroup;
                        children = (
                                5C4B471F1E42AAD6002651C8 /* ber.c in Sources */,
                                5C4B473B1E42AAEA002651C8 /* bio.c in Sources */,
                                5C4B473A1E42AAEA002651C8 /* bio_mem.c in Sources */,
+                               5CFACF35226E96ED0056C7D0 /* bio_ssl.cc in Sources */,
                                41A391841EFC447C00C4516A /* blinding.c in Sources */,
                                41EA53FE1EFC2D1B002FF04C /* bn.c in Sources */,
                                41A391BB1EFC45CD00C4516A /* bn_asn1.c in Sources */,
                                41A3917F1EFC447C00C4516A /* ctrdrbg.c in Sources */,
                                41EA54021EFC2D1B002FF04C /* ctx.c in Sources */,
                                419C84CB1FE3252E0040C30F /* curve25519.c in Sources */,
+                               5CFACF36226E96F20056C7D0 /* d1_both.cc in Sources */,
+                               5CFACF37226E96F70056C7D0 /* d1_lib.cc in Sources */,
+                               5CFACF38226E96FB0056C7D0 /* d1_pkt.cc in Sources */,
+                               5CFACF39226E96FE0056C7D0 /* d1_srtp.cc in Sources */,
                                41A391AA1EFC454F00C4516A /* derive_key.c in Sources */,
                                41A391E81EFC490400C4516A /* des.c in Sources */,
                                5C4B470B1E42AABE002651C8 /* dh.c in Sources */,
                                415449A721CAC39A001C0A55 /* div_extra.c in Sources */,
                                5C4B47041E42AAB4002651C8 /* dsa.c in Sources */,
                                5C4B48471E42C0F6002651C8 /* dsa_asn1.c in Sources */,
+                               5CFACF3A226E97050056C7D0 /* dtls_method.cc in Sources */,
+                               5CFACF3B226E97080056C7D0 /* dtls_record.cc in Sources */,
                                41A392201EFC5CF500C4516A /* e_aes.c in Sources */,
                                41A391AB1EFC454F00C4516A /* e_aesctrhmac.c in Sources */,
                                41A391AC1EFC454F00C4516A /* e_aesgcmsiv.c in Sources */,
                                41A391E31EFC48AE00C4516A /* ecdsa_asn1.c in Sources */,
                                5C4B46F21E42AAA1002651C8 /* engine.c in Sources */,
                                5C4B46F11E42AA9C002651C8 /* err.c in Sources */,
+                               5CFACF58226E97CD0056C7D0 /* err_data.c in Sources */,
                                5C4B46E61E42AA97002651C8 /* evp.c in Sources */,
                                5C4B46E41E42AA97002651C8 /* evp_asn1.c in Sources */,
                                5C4B46E51E42AA97002651C8 /* evp_ctx.c in Sources */,
                                415449A821CAC39A001C0A55 /* gcd_extra.c in Sources */,
                                41A3917A1EFC447C00C4516A /* gcm.c in Sources */,
                                41EA54061EFC2D1B002FF04C /* generic.c in Sources */,
+                               5CFACF3C226E970C0056C7D0 /* handshake.cc in Sources */,
+                               5CFACF3D226E970F0056C7D0 /* handshake_client.cc in Sources */,
+                               5CFACF3E226E97120056C7D0 /* handshake_server.cc in Sources */,
                                5C4B47401E42AAEA002651C8 /* hexdump.c in Sources */,
                                5C4B46E21E42AA92002651C8 /* hkdf.c in Sources */,
                                41EA53A51EFC2C14002FF04C /* hmac.c in Sources */,
                                5C4B46C61E42AA6B002651C8 /* pem_pkey.c in Sources */,
                                5C4B46C71E42AA6B002651C8 /* pem_x509.c in Sources */,
                                5C4B46C81E42AA6B002651C8 /* pem_xaux.c in Sources */,
+                               5CFACF5F226E9A1E0056C7D0 /* pkcs7.c in Sources */,
+                               5CFACF5E226E9A1E0056C7D0 /* pkcs7_x509.c in Sources */,
                                5C4B46BF1E42AA66002651C8 /* pkcs8.c in Sources */,
                                41A391BE1EFC460D00C4516A /* pkcs8_x509.c in Sources */,
                                5C4B46B91E42AA61002651C8 /* poly1305.c in Sources */,
                                41A391881EFC447C00C4516A /* rsa_impl.c in Sources */,
                                5C4B467A1E42AA3C002651C8 /* rsa_pss.c in Sources */,
                                41EA540E1EFC2D1B002FF04C /* rsaz_exp.c in Sources */,
+                               5CFACF3F226E97180056C7D0 /* s3_both.cc in Sources */,
+                               5CFACF40226E971C0056C7D0 /* s3_lib.cc in Sources */,
+                               5CFACF41226E971F0056C7D0 /* s3_pkt.cc in Sources */,
                                415449B121CAC3F5001C0A55 /* scalar.c in Sources */,
                                41A391731EFC447C00C4516A /* sha1-altivec.c in Sources */,
                                41A391741EFC447C00C4516A /* sha1.c in Sources */,
                                5C4B47441E42AAEA002651C8 /* socket_helper.c in Sources */,
                                5C4B4D021E432185002651C8 /* spake25519.c in Sources */,
                                41EA54111EFC2D1B002FF04C /* sqrt.c in Sources */,
+                               5CFACF43226E97350056C7D0 /* ssl_aead_ctx.cc in Sources */,
+                               5CFACF44226E97390056C7D0 /* ssl_asn1.cc in Sources */,
+                               5CFACF45226E973C0056C7D0 /* ssl_buffer.cc in Sources */,
+                               5CFACF46226E97400056C7D0 /* ssl_cert.cc in Sources */,
+                               5CFACF47226E975D0056C7D0 /* ssl_cipher.cc in Sources */,
+                               5CFACF48226E97610056C7D0 /* ssl_file.cc in Sources */,
+                               5CFACF49226E97650056C7D0 /* ssl_key_share.cc in Sources */,
+                               5CFACF33226E96BD0056C7D0 /* ssl_lib.cc in Sources */,
+                               5CFACF4A226E976B0056C7D0 /* ssl_privkey.cc in Sources */,
+                               5CFACF34226E96E60056C7D0 /* ssl_session.cc in Sources */,
+                               5CFACF4B226E97710056C7D0 /* ssl_stat.cc in Sources */,
+                               5CFACF4D226E97780056C7D0 /* ssl_transcript.cc in Sources */,
+                               5CFACF4E226E977D0056C7D0 /* ssl_versions.cc in Sources */,
+                               5CFACF4F226E977F0056C7D0 /* ssl_x509.cc in Sources */,
                                5C4B46A51E42AA42002651C8 /* stack.c in Sources */,
+                               5CFACF50226E97830056C7D0 /* t1_enc.cc in Sources */,
+                               5CFACF51226E97860056C7D0 /* t1_lib.cc in Sources */,
                                5C4B467B1E42AA3C002651C8 /* t_crl.c in Sources */,
                                5C4B467C1E42AA3C002651C8 /* t_req.c in Sources */,
                                5C4B467D1E42AA3C002651C8 /* t_x509.c in Sources */,
                                5C4B46441E42AA2C002651C8 /* thread_pthread.c in Sources */,
                                5C4B46461E42AA2C002651C8 /* thread_win.c in Sources */,
                                41A392031EFC495B00C4516A /* time_support.c in Sources */,
+                               5CFACF52226E978A0056C7D0 /* tls13_both.cc in Sources */,
+                               5CFACF53226E978D0056C7D0 /* tls13_client.cc in Sources */,
+                               5CFACF54226E97910056C7D0 /* tls13_enc.cc in Sources */,
+                               5CFACF55226E97950056C7D0 /* tls13_server.cc in Sources */,
                                41A391B41EFC454F00C4516A /* tls_cbc.c in Sources */,
+                               5CFACF56226E97980056C7D0 /* tls_method.cc in Sources */,
+                               5CFACF57226E979C0056C7D0 /* tls_record.cc in Sources */,
                                415449A221CAC34D001C0A55 /* unicode.c in Sources */,
                                41A391831EFC447C00C4516A /* urandom.c in Sources */,
                                415449B621CAC4CE001C0A55 /* util.c in Sources */,
                                5C4B4D091E4322F6002651C8 /* basicportallocator.cc in Sources */,
                                419241C92127593F00634FCF /* bbr_factory.cc in Sources */,
                                419241C72127593F00634FCF /* bbr_network_controller.cc in Sources */,
-                               419C846F1FE255FA0040C30F /* bio_ssl.cc in Sources */,
                                416D3BE0212731C200775F09 /* biquad_filter.cc in Sources */,
                                413A233B1FE18E0700373E99 /* bitbuffer.cc in Sources */,
                                5C4B4C191E431F75002651C8 /* bitrate_adjuster.cc in Sources */,
                                5CDD8A0F1E43BFB300621E92 /* cross_correlation.cc in Sources */,
                                41FCBB3121B1F8B700A5DF27 /* cryptooptions.cc in Sources */,
                                413A23221FE18E0700373E99 /* cryptstring.cc in Sources */,
-                               419C848C1FE2574D0040C30F /* d1_both.cc in Sources */,
-                               419C848D1FE2574D0040C30F /* d1_lib.cc in Sources */,
-                               419C848F1FE2574D0040C30F /* d1_pkt.cc in Sources */,
-                               419C84871FE2574D0040C30F /* d1_srtp.cc in Sources */,
                                419241E121275A3000634FCF /* data_rate.cc in Sources */,
                                41E02CC02127356A00C27CD6 /* data_rate_limiter.cc in Sources */,
                                419241DF21275A3000634FCF /* data_size.cc in Sources */,
                                5CDD86501E43B8B500621E92 /* downsample_fast.c in Sources */,
                                4145E4D61EF8CC7600FCF6E6 /* downsampled_render_buffer.cc in Sources */,
                                5CDD8A231E43BFB300621E92 /* dsp_helper.cc in Sources */,
-                               419C84881FE2574D0040C30F /* dtls_method.cc in Sources */,
-                               419C848A1FE2574D0040C30F /* dtls_record.cc in Sources */,
                                419C82E41FE20E590040C30F /* dtlssrtptransport.cc in Sources */,
                                419C83E11FE247F20040C30F /* dtlstransport.cc in Sources */,
                                419C83DE1FE247F20040C30F /* dtlstransportinternal.cc in Sources */,
                                41433D151F79B33400387B4D /* entropy_coding.c in Sources */,
                                5CD285C21E6A63430094FDC8 /* erl_estimator.cc in Sources */,
                                5CD285C41E6A63430094FDC8 /* erle_estimator.cc in Sources */,
-                               419C84921FE2591F0040C30F /* err_data.c in Sources */,
                                5C4B4CD21E4320A9002651C8 /* event.cc in Sources */,
                                413A23B71FE18E0800373E99 /* event.cc in Sources */,
                                5CD286141E6A66130094FDC8 /* event_log_writer.cc in Sources */,
                                4145E4BF1EF894F600FCF6E6 /* h264_profile_level_id.cc in Sources */,
                                5CD285EA1E6A639F0094FDC8 /* h264_sprop_parameter_sets.cc in Sources */,
                                5CDD83D91E439A6F00621E92 /* h264_sps_pps_tracker.cc in Sources */,
-                               419C84691FE255FA0040C30F /* handshake.cc in Sources */,
-                               419C84891FE2574D0040C30F /* handshake_client.cc in Sources */,
-                               419C848B1FE2574D0040C30F /* handshake_server.cc in Sources */,
                                41FCBB7121B1FF7400A5DF27 /* hdr_metadata.cc in Sources */,
                                413A236E1FE18E0700373E99 /* helpers.cc in Sources */,
                                417953BC2169824B0028266B /* helpers.cc in Sources */,
                                419C82B71FE20DCD0040C30F /* rtx_receive_stream.cc in Sources */,
                                419241642127385B00634FCF /* rw_lock_posix.cc in Sources */,
                                419241612127385B00634FCF /* rw_lock_wrapper.cc in Sources */,
-                               419C84701FE255FA0040C30F /* s3_both.cc in Sources */,
-                               419C84771FE255FA0040C30F /* s3_lib.cc in Sources */,
-                               419C84731FE255FA0040C30F /* s3_pkt.cc in Sources */,
                                41E02CD42127360700C27CD6 /* sample_counter.cc in Sources */,
                                416D3BE9212731C200775F09 /* saturation_protector.cc in Sources */,
                                5CFD53931E4BD3A300482908 /* scale_neon.cc in Sources */,
                                5CDD83621E43257200621E92 /* sps_vui_rewriter.cc in Sources */,
                                5CDD86721E43B8B500621E92 /* sqrt_of_one_minus_x_squared.c in Sources */,
                                419C82DF1FE20E590040C30F /* srtptransport.cc in Sources */,
-                               419C845E1FE255FA0040C30F /* ssl_aead_ctx.cc in Sources */,
-                               419C84741FE255FA0040C30F /* ssl_asn1.cc in Sources */,
-                               419C84601FE255FA0040C30F /* ssl_buffer.cc in Sources */,
-                               419C84751FE255FA0040C30F /* ssl_cert.cc in Sources */,
-                               419C84651FE255FA0040C30F /* ssl_cipher.cc in Sources */,
-                               419C84721FE255FA0040C30F /* ssl_file.cc in Sources */,
-                               419C84781FE255FA0040C30F /* ssl_key_share.cc in Sources */,
-                               419C84761FE255FA0040C30F /* ssl_lib.cc in Sources */,
-                               419C846C1FE255FA0040C30F /* ssl_privkey.cc in Sources */,
-                               419C845F1FE255FA0040C30F /* ssl_session.cc in Sources */,
-                               419C84611FE255FA0040C30F /* ssl_stat.cc in Sources */,
-                               419C84621FE255FA0040C30F /* ssl_transcript.cc in Sources */,
-                               419C846E1FE255FA0040C30F /* ssl_versions.cc in Sources */,
-                               419C84641FE255FA0040C30F /* ssl_x509.cc in Sources */,
                                419C843E1FE250490040C30F /* ssladapter.cc in Sources */,
                                41E02CBE2127356A00C27CD6 /* sslcertificate.cc in Sources */,
                                413A23F11FE18E0800373E99 /* sslfingerprint.cc in Sources */,
                                5CDD8BEF1E43C2B500621E92 /* swap_bytes.c in Sources */,
                                5CDD8A541E43BFB300621E92 /* sync_buffer.cc in Sources */,
                                5CD284BE1E6A5F9F0094FDC8 /* syncable.cc in Sources */,
-                               419C846D1FE255FA0040C30F /* t1_enc.cc in Sources */,
-                               419C84791FE255FA0040C30F /* t1_lib.cc in Sources */,
                                5CDD89781E43BF3A00621E92 /* target_bitrate.cc in Sources */,
                                413A23DE1FE18E0800373E99 /* task_queue_gcd.cc in Sources */,
                                413A232D1FE18E0700373E99 /* task_queue_posix.cc in Sources */,
                                413A237B1FE18E0700373E99 /* timestampaligner.cc in Sources */,
                                413A23C31FE18E0800373E99 /* timeutils.cc in Sources */,
                                5CDD83FF1E439A6F00621E92 /* timing.cc in Sources */,
-                               419C84681FE255FA0040C30F /* tls13_both.cc in Sources */,
-                               419C84671FE255FA0040C30F /* tls13_client.cc in Sources */,
-                               419C84631FE255FA0040C30F /* tls13_enc.cc in Sources */,
-                               419C845D1FE255FA0040C30F /* tls13_server.cc in Sources */,
-                               419C846B1FE255FA0040C30F /* tls_method.cc in Sources */,
-                               419C84661FE255FA0040C30F /* tls_record.cc in Sources */,
                                5CDD897A1E43BF3A00621E92 /* tmmb_item.cc in Sources */,
                                5CDD897D1E43BF3A00621E92 /* tmmbn.cc in Sources */,
                                5CDD89801E43BF3A00621E92 /* tmmbr.cc in Sources */,
index 21e0d6e..53db782 100644 (file)
@@ -1,3 +1,32 @@
+2019-04-23  Alex Christensen  <achristensen@webkit.org>
+
+        Add unit tests for WKWebView.serverTrust
+        https://bugs.webkit.org/show_bug.cgi?id=197202
+
+        Reviewed by Youenn Fablet
+
+        * TestWebKitAPI/TCPServer.cpp:
+        (TestWebKitAPI::deleter<BIO>::operator()):
+        (TestWebKitAPI::deleter<SSL>::operator()):
+        (TestWebKitAPI::deleter<X509>::operator()):
+        (TestWebKitAPI::deleter<SSL_CTX>::operator()):
+        (TestWebKitAPI::deleter<EVP_PKEY>::operator()):
+        (TestWebKitAPI::TCPServer::TCPServer):
+        (TestWebKitAPI::TCPServer::listenForConnections):
+        * TestWebKitAPI/TCPServer.h:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
+        (TestWebKitAPI::TEST):
+        (verifyCertificateAndPublicKey):
+        (-[ServerTrustDelegate webView:didFinishNavigation:]):
+        (-[ServerTrustDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]):
+        * TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
+        (TestWebKitAPI::downloadAtRate):
+        * TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm:
+        (TEST):
+
 2019-04-23  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r244556.
index 44ac1e3..1fbb191 100644 (file)
 #include <unistd.h>
 #include <wtf/Optional.h>
 
+extern "C" {
+
+struct BIO;
+struct X509;
+struct SSL_CTX;
+struct EVP_PKEY;
+struct SSL_METHOD;
+struct pem_password_cb;
+int BIO_free(BIO*);
+int SSL_free(SSL*);
+int X509_free(X509*);
+int SSL_CTX_free(SSL_CTX*);
+int EVP_PKEY_free(EVP_PKEY*);
+int SSL_library_init();
+const SSL_METHOD* SSLv23_server_method();
+BIO* BIO_new_mem_buf(const void*, int);
+X509* PEM_read_bio_X509(BIO*, X509**, pem_password_cb*, void*);
+EVP_PKEY* PEM_read_bio_PrivateKey(BIO*, EVP_PKEY**, pem_password_cb*, void*);
+SSL_CTX* SSL_CTX_new(const SSL_METHOD*);
+const SSL_METHOD* SSLv23_server_method();
+int SSL_CTX_use_certificate(SSL_CTX*, X509*);
+int SSL_CTX_use_PrivateKey(SSL_CTX*, EVP_PKEY*);
+SSL* SSL_new(SSL_CTX*);
+int SSL_accept(SSL*);
+int SSL_set_fd(SSL*, int);
+
+} // extern "C"
+
 namespace TestWebKitAPI {
 
+template<typename> struct deleter;
+template<> struct deleter<BIO> {
+    void operator()(BIO* bio)
+    {
+        BIO_free(bio);
+    }
+};
+template<> struct deleter<SSL> {
+    void operator()(SSL* ssl)
+    {
+        SSL_free(ssl);
+    }
+};
+template<> struct deleter<X509> {
+    void operator()(X509* x509)
+    {
+        X509_free(x509);
+    }
+};
+template<> struct deleter<SSL_CTX> {
+    void operator()(SSL_CTX* ctx)
+    {
+        SSL_CTX_free(ctx);
+    }
+};
+template<> struct deleter<EVP_PKEY> {
+    void operator()(EVP_PKEY* key)
+    {
+        EVP_PKEY_free(key);
+    }
+};
+
 TCPServer::TCPServer(Function<void(Socket)>&& connectionHandler, size_t connections)
     : m_connectionHandler(WTFMove(connectionHandler))
 {
+    listenForConnections(connections);
+}
+
+TCPServer::TCPServer(Function<void(SSL*)>&& secureConnectionHandler)
+    : m_connectionHandler([secureConnectionHandler = WTFMove(secureConnectionHandler)] (Socket socket) {
+
+        SSL_library_init();
+
+        std::unique_ptr<SSL_CTX, deleter<SSL_CTX>> ctx(SSL_CTX_new(SSLv23_server_method()));
+
+        // This is a test certificate from BoringSSL.
+        char kCertPEM[] =
+        "-----BEGIN CERTIFICATE-----\n"
+        "MIICWDCCAcGgAwIBAgIJAPuwTC6rEJsMMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV\n"
+        "BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\n"
+        "aWRnaXRzIFB0eSBMdGQwHhcNMTQwNDIzMjA1MDQwWhcNMTcwNDIyMjA1MDQwWjBF\n"
+        "MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50\n"
+        "ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n"
+        "gQDYK8imMuRi/03z0K1Zi0WnvfFHvwlYeyK9Na6XJYaUoIDAtB92kWdGMdAQhLci\n"
+        "HnAjkXLI6W15OoV3gA/ElRZ1xUpxTMhjP6PyY5wqT5r6y8FxbiiFKKAnHmUcrgfV\n"
+        "W28tQ+0rkLGMryRtrukXOgXBv7gcrmU7G1jC2a7WqmeI8QIDAQABo1AwTjAdBgNV\n"
+        "HQ4EFgQUi3XVrMsIvg4fZbf6Vr5sp3Xaha8wHwYDVR0jBBgwFoAUi3XVrMsIvg4f\n"
+        "Zbf6Vr5sp3Xaha8wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQA76Hht\n"
+        "ldY9avcTGSwbwoiuIqv0jTL1fHFnzy3RHMLDh+Lpvolc5DSrSJHCP5WuK0eeJXhr\n"
+        "T5oQpHL9z/cCDLAKCKRa4uV0fhEdOWBqyR9p8y5jJtye72t6CuFUV5iqcpF4BH4f\n"
+        "j2VNHwsSrJwkD4QUGlUtH7vwnQmyCFxZMmWAJg==\n"
+        "-----END CERTIFICATE-----\n";
+
+        std::unique_ptr<BIO, deleter<BIO>> certBIO(BIO_new_mem_buf(kCertPEM, strlen(kCertPEM)));
+        std::unique_ptr<X509, deleter<X509>> certX509(PEM_read_bio_X509(certBIO.get(), nullptr, nullptr, nullptr));
+        ASSERT(certX509);
+        SSL_CTX_use_certificate(ctx.get(), certX509.get());
+
+        // This is a test key from BoringSSL.
+        char kKeyPEM[] =
+        "-----BEGIN RSA PRIVATE KEY-----\n"
+        "MIICXgIBAAKBgQDYK8imMuRi/03z0K1Zi0WnvfFHvwlYeyK9Na6XJYaUoIDAtB92\n"
+        "kWdGMdAQhLciHnAjkXLI6W15OoV3gA/ElRZ1xUpxTMhjP6PyY5wqT5r6y8FxbiiF\n"
+        "KKAnHmUcrgfVW28tQ+0rkLGMryRtrukXOgXBv7gcrmU7G1jC2a7WqmeI8QIDAQAB\n"
+        "AoGBAIBy09Fd4DOq/Ijp8HeKuCMKTHqTW1xGHshLQ6jwVV2vWZIn9aIgmDsvkjCe\n"
+        "i6ssZvnbjVcwzSoByhjN8ZCf/i15HECWDFFh6gt0P5z0MnChwzZmvatV/FXCT0j+\n"
+        "WmGNB/gkehKjGXLLcjTb6dRYVJSCZhVuOLLcbWIV10gggJQBAkEA8S8sGe4ezyyZ\n"
+        "m4e9r95g6s43kPqtj5rewTsUxt+2n4eVodD+ZUlCULWVNAFLkYRTBCASlSrm9Xhj\n"
+        "QpmWAHJUkQJBAOVzQdFUaewLtdOJoPCtpYoY1zd22eae8TQEmpGOR11L6kbxLQsk\n"
+        "aMly/DOnOaa82tqAGTdqDEZgSNmCeKKknmECQAvpnY8GUOVAubGR6c+W90iBuQLj\n"
+        "LtFp/9ihd2w/PoDwrHZaoUYVcT4VSfJQog/k7kjE4MYXYWL8eEKg3WTWQNECQQDk\n"
+        "104Wi91Umd1PzF0ijd2jXOERJU1wEKe6XLkYYNHWQAe5l4J4MWj9OdxFXAxIuuR/\n"
+        "tfDwbqkta4xcux67//khAkEAvvRXLHTaa6VFzTaiiO8SaFsHV3lQyXOtMrBpB5jd\n"
+        "moZWgjHvB2W9Ckn7sDqsPB+U2tyX0joDdQEyuiMECDY8oQ==\n"
+        "-----END RSA PRIVATE KEY-----\n";
+
+        std::unique_ptr<BIO, deleter<BIO>> privateKeyBIO(BIO_new_mem_buf(kKeyPEM, strlen(kKeyPEM)));
+        std::unique_ptr<EVP_PKEY, deleter<EVP_PKEY>> privateKey(PEM_read_bio_PrivateKey(privateKeyBIO.get(), nullptr, nullptr, nullptr));
+        ASSERT(privateKey);
+        SSL_CTX_use_PrivateKey(ctx.get(), privateKey.get());
+
+        std::unique_ptr<SSL, deleter<SSL>> ssl(SSL_new(ctx.get()));
+        ASSERT(ssl);
+        SSL_set_fd(ssl.get(), socket);
+
+        auto acceptResult = SSL_accept(ssl.get());
+        ASSERT_UNUSED(acceptResult, acceptResult > 0);
+        
+        secureConnectionHandler(ssl.get());
+    })
+{
+    listenForConnections(1);
+}
+
+void TCPServer::listenForConnections(size_t connections)
+{
     auto listeningSocket = socketBindListen(connections);
     ASSERT(listeningSocket);
     m_listeningThread = std::thread([this, listeningSocket = *listeningSocket, connections] {
index b9a23f3..e62621f 100644 (file)
 #include <wtf/Function.h>
 #include <wtf/Vector.h>
 
+extern "C" {
+struct SSL;
+int SSL_read(SSL*, void*, int);
+int SSL_write(SSL*, const void*, int);
+}
+
 namespace TestWebKitAPI {
 
 class TCPServer {
@@ -37,13 +43,15 @@ public:
     using Port = uint16_t;
     static constexpr Port InvalidPort = 0;
     
-    TCPServer(Function<void(Socket)>&&, size_t connections = 1);
+    TCPServer(Function<void(Socket)>&&, size_t connections);
+    TCPServer(Function<void(SSL*)>&&);
     ~TCPServer();
     
     Port port() const { return m_port; }
     
 private:
     Optional<Socket> socketBindListen(size_t connections);
+    void listenForConnections(size_t connections);
 
     Port m_port { InvalidPort };
     std::thread m_listeningThread;
index f329665..13819a8 100644 (file)
                5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; };
                5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; };
                5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */; };
+               5CFACF63226F73C60056C7D0 /* libboringssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFACF62226F73C60056C7D0 /* libboringssl.a */; };
                5E4B1D2E1D404C6100053621 /* WKScrollViewDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */; };
                631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */; };
                634910E01E9D3FF300880309 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 634910DF1E9D3FF300880309 /* CoreLocation.framework */; };
                5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; };
                5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; };
                5CF540E82257E64B00E6BC0E /* DownloadThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadThread.mm; sourceTree = "<group>"; };
+               5CFACF62226F73C60056C7D0 /* libboringssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libboringssl.a; sourceTree = BUILT_PRODUCTS_DIR; };
                5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegate.mm; path = ../ios/WKScrollViewDelegate.mm; sourceTree = "<group>"; };
                631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Geolocation.mm; sourceTree = "<group>"; };
                634910DF1E9D3FF300880309 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
                                7A010BCB1D877C0500EDE72A /* CoreGraphics.framework in Frameworks */,
                                634910E01E9D3FF300880309 /* CoreLocation.framework in Frameworks */,
                                CDA3159D1ED5643F009F60D3 /* IOKit.framework in Frameworks */,
+                               5CFACF63226F73C60056C7D0 /* libboringssl.a in Frameworks */,
                                7C83E03F1D0A61A000FEBCF3 /* libicucore.dylib in Frameworks */,
                                578CBD67204FB2C80083B9F2 /* LocalAuthentication.framework in Frameworks */,
                                7A010BCD1D877C0D00EDE72A /* QuartzCore.framework in Frameworks */,
                                634910DF1E9D3FF300880309 /* CoreLocation.framework */,
                                0F4FFAA01ED3D0DE00F7111F /* ImageIO.framework */,
                                CDA3159C1ED5643F009F60D3 /* IOKit.framework */,
+                               5CFACF62226F73C60056C7D0 /* libboringssl.a */,
                                7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */,
                                A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */,
                                4135FB862011FABF00332139 /* libWebCoreTestSupport.dylib */,
index cd2b09a..d9736ac 100644 (file)
@@ -238,7 +238,7 @@ namespace TestWebKitAPI {
 
 TEST(Challenge, SecIdentity)
 {
-    TCPServer server(respondWithChallengeThenOK);
+    TCPServer server(respondWithChallengeThenOK, 1);
 
     auto webView = adoptNS([WKWebView new]);
     auto delegate = adoptNS([ChallengeDelegate new]);
@@ -308,3 +308,120 @@ TEST(Challenge, BasicProposedCredential)
     }];
     Util::run(&removedCredential);
 }
+
+static void verifyCertificateAndPublicKey(SecTrustRef trust)
+{
+    EXPECT_NOT_NULL(trust);
+
+    auto compareData = [] (const RetainPtr<CFDataRef>& data, const Vector<uint8_t>& expected) {
+        size_t length = CFDataGetLength(data.get());
+        EXPECT_EQ(length, expected.size());
+        const UInt8* bytes = CFDataGetBytePtr(data.get());
+        for (size_t i = 0; i < length; ++i)
+            EXPECT_EQ(expected[i], bytes[i]);
+    };
+
+    auto publicKey = adoptCF(SecKeyCopyExternalRepresentation(adoptCF(SecTrustCopyPublicKey(trust)).get(), nullptr));
+    compareData(publicKey, {
+        0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xd8, 0x2b, 0xc8, 0xa6, 0x32, 0xe4, 0x62, 0xff, 0x4d,
+        0xf3, 0xd0, 0xad, 0x59, 0x8b, 0x45, 0xa7, 0xbd, 0xf1, 0x47, 0xbf, 0x09, 0x58, 0x7b, 0x22, 0xbd,
+        0x35, 0xae, 0x97, 0x25, 0x86, 0x94, 0xa0, 0x80, 0xc0, 0xb4, 0x1f, 0x76, 0x91, 0x67, 0x46, 0x31,
+        0xd0, 0x10, 0x84, 0xb7, 0x22, 0x1e, 0x70, 0x23, 0x91, 0x72, 0xc8, 0xe9, 0x6d, 0x79, 0x3a, 0x85,
+        0x77, 0x80, 0x0f, 0xc4, 0x95, 0x16, 0x75, 0xc5, 0x4a, 0x71, 0x4c, 0xc8, 0x63, 0x3f, 0xa3, 0xf2,
+        0x63, 0x9c, 0x2a, 0x4f, 0x9a, 0xfa, 0xcb, 0xc1, 0x71, 0x6e, 0x28, 0x85, 0x28, 0xa0, 0x27, 0x1e,
+        0x65, 0x1c, 0xae, 0x07, 0xd5, 0x5b, 0x6f, 0x2d, 0x43, 0xed, 0x2b, 0x90, 0xb1, 0x8c, 0xaf, 0x24,
+        0x6d, 0xae, 0xe9, 0x17, 0x3a, 0x05, 0xc1, 0xbf, 0xb8, 0x1c, 0xae, 0x65, 0x3b, 0x1b, 0x58, 0xc2,
+        0xd9, 0xae, 0xd6, 0xaa, 0x67, 0x88, 0xf1, 0x02, 0x03, 0x01, 0x00, 0x01
+    });
+    
+    EXPECT_EQ(1, SecTrustGetCertificateCount(trust));
+    auto certificate = adoptCF(SecCertificateCopyData(SecTrustGetCertificateAtIndex(trust, 0)));
+    compareData(certificate, {
+        0x30, 0x82, 0x02, 0x58, 0x30, 0x82, 0x01, 0xc1, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
+        0xfb, 0xb0, 0x4c, 0x2e, 0xab, 0x10, 0x9b, 0x0c, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+        0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x45, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
+        0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c,
+        0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61, 0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06,
+        0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57,
+        0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74, 0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x1e,
+        0x17, 0x0d, 0x31, 0x34, 0x30, 0x34, 0x32, 0x33, 0x32, 0x30, 0x35, 0x30, 0x34, 0x30, 0x5a, 0x17,
+        0x0d, 0x31, 0x37, 0x30, 0x34, 0x32, 0x32, 0x32, 0x30, 0x35, 0x30, 0x34, 0x30, 0x5a, 0x30, 0x45,
+        0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x41, 0x55, 0x31, 0x13, 0x30,
+        0x11, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0c, 0x0a, 0x53, 0x6f, 0x6d, 0x65, 0x2d, 0x53, 0x74, 0x61,
+        0x74, 0x65, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x18, 0x49, 0x6e, 0x74,
+        0x65, 0x72, 0x6e, 0x65, 0x74, 0x20, 0x57, 0x69, 0x64, 0x67, 0x69, 0x74, 0x73, 0x20, 0x50, 0x74,
+        0x79, 0x20, 0x4c, 0x74, 0x64, 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+        0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81,
+        0x81, 0x00, 0xd8, 0x2b, 0xc8, 0xa6, 0x32, 0xe4, 0x62, 0xff, 0x4d, 0xf3, 0xd0, 0xad, 0x59, 0x8b,
+        0x45, 0xa7, 0xbd, 0xf1, 0x47, 0xbf, 0x09, 0x58, 0x7b, 0x22, 0xbd, 0x35, 0xae, 0x97, 0x25, 0x86,
+        0x94, 0xa0, 0x80, 0xc0, 0xb4, 0x1f, 0x76, 0x91, 0x67, 0x46, 0x31, 0xd0, 0x10, 0x84, 0xb7, 0x22,
+        0x1e, 0x70, 0x23, 0x91, 0x72, 0xc8, 0xe9, 0x6d, 0x79, 0x3a, 0x85, 0x77, 0x80, 0x0f, 0xc4, 0x95,
+        0x16, 0x75, 0xc5, 0x4a, 0x71, 0x4c, 0xc8, 0x63, 0x3f, 0xa3, 0xf2, 0x63, 0x9c, 0x2a, 0x4f, 0x9a,
+        0xfa, 0xcb, 0xc1, 0x71, 0x6e, 0x28, 0x85, 0x28, 0xa0, 0x27, 0x1e, 0x65, 0x1c, 0xae, 0x07, 0xd5,
+        0x5b, 0x6f, 0x2d, 0x43, 0xed, 0x2b, 0x90, 0xb1, 0x8c, 0xaf, 0x24, 0x6d, 0xae, 0xe9, 0x17, 0x3a,
+        0x05, 0xc1, 0xbf, 0xb8, 0x1c, 0xae, 0x65, 0x3b, 0x1b, 0x58, 0xc2, 0xd9, 0xae, 0xd6, 0xaa, 0x67,
+        0x88, 0xf1, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55,
+        0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x8b, 0x75, 0xd5, 0xac, 0xcb, 0x08, 0xbe, 0x0e, 0x1f, 0x65,
+        0xb7, 0xfa, 0x56, 0xbe, 0x6c, 0xa7, 0x75, 0xda, 0x85, 0xaf, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d,
+        0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x8b, 0x75, 0xd5, 0xac, 0xcb, 0x08, 0xbe, 0x0e, 0x1f,
+        0x65, 0xb7, 0xfa, 0x56, 0xbe, 0x6c, 0xa7, 0x75, 0xda, 0x85, 0xaf, 0x30, 0x0c, 0x06, 0x03, 0x55,
+        0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
+        0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x3b, 0xe8, 0x78, 0x6d,
+        0x95, 0xd6, 0x3d, 0x6a, 0xf7, 0x13, 0x19, 0x2c, 0x1b, 0xc2, 0x88, 0xae, 0x22, 0xab, 0xf4, 0x8d,
+        0x32, 0xf5, 0x7c, 0x71, 0x67, 0xcf, 0x2d, 0xd1, 0x1c, 0xc2, 0xc3, 0x87, 0xe2, 0xe9, 0xbe, 0x89,
+        0x5c, 0xe4, 0x34, 0xab, 0x48, 0x91, 0xc2, 0x3f, 0x95, 0xae, 0x2b, 0x47, 0x9e, 0x25, 0x78, 0x6b,
+        0x4f, 0x9a, 0x10, 0xa4, 0x72, 0xfd, 0xcf, 0xf7, 0x02, 0x0c, 0xb0, 0x0a, 0x08, 0xa4, 0x5a, 0xe2,
+        0xe5, 0x74, 0x7e, 0x11, 0x1d, 0x39, 0x60, 0x6a, 0xc9, 0x1f, 0x69, 0xf3, 0x2e, 0x63, 0x26, 0xdc,
+        0x9e, 0xef, 0x6b, 0x7a, 0x0a, 0xe1, 0x54, 0x57, 0x98, 0xaa, 0x72, 0x91, 0x78, 0x04, 0x7e, 0x1f,
+        0x8f, 0x65, 0x4d, 0x1f, 0x0b, 0x12, 0xac, 0x9c, 0x24, 0x0f, 0x84, 0x14, 0x1a, 0x55, 0x2d, 0x1f,
+        0xbb, 0xf0, 0x9d, 0x09, 0xb2, 0x08, 0x5c, 0x59, 0x32, 0x65, 0x80, 0x26
+    });
+}
+
+@interface ServerTrustDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation ServerTrustDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation
+{
+    navigationFinished = true;
+}
+
+- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler
+{
+    SecTrustRef trust = challenge.protectionSpace.serverTrust;
+    verifyCertificateAndPublicKey(trust);
+    completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:trust]);
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit, ServerTrust)
+{
+    TCPServer server([] (SSL* ssl) {
+        char requestBuffer[1000];
+        auto readResult = SSL_read(ssl, requestBuffer, sizeof(requestBuffer));
+        ASSERT_UNUSED(readResult, readResult > 0);
+
+        const char* reply = ""
+        "HTTP/1.1 200 OK\r\n"
+        "Content-Length: 13\r\n\r\n"
+        "Hello, World!";
+        auto writeResult = SSL_write(ssl, reply, strlen(reply));
+        ASSERT_UNUSED(writeResult, writeResult == static_cast<int>(strlen(reply)));
+    });
+
+    auto webView = adoptNS([WKWebView new]);
+    auto delegate = adoptNS([ServerTrustDelegate new]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://localhost:%d/", server.port()]]]];
+    TestWebKitAPI::Util::run(&navigationFinished);
+
+    verifyCertificateAndPublicKey([webView serverTrust]);
+}
+
+} // namespace TestWebKitAPI
index cc3a986..d8b009e 100644 (file)
@@ -861,9 +861,9 @@ enum class AppReturnsToForeground { No, Yes };
 void downloadAtRate(double desiredKbps, unsigned speedMultiplier, AppReturnsToForeground returnToForeground = AppReturnsToForeground::No)
 {
     bool terminateServer = false;
-    TCPServer server([&](auto socket) {
+    TCPServer server([&](int socket) {
         respondSlowly(socket, desiredKbps, terminateServer);
-    });
+    }, 1);
     
     auto webView = webViewWithDownloadMonitorSpeedMultiplier(speedMultiplier);
     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]];
index 345124f..94e56eb 100644 (file)
@@ -72,7 +72,7 @@ static RetainPtr<NSData> createPDFWithLinkToURL(NSURL *url)
 
 TEST(WebKit, PDFLinkReferrer)
 {
-    TestWebKitAPI::TCPServer server([] (auto socket) {
+    TestWebKitAPI::TCPServer server([] (int socket) {
         char readBuffer[1000];
         memset(readBuffer, 0, 1000);
 
@@ -92,7 +92,7 @@ TEST(WebKit, PDFLinkReferrer)
         "HTTP/1.1 200 OK\r\n"
         "Content-Length: 0\r\n\r\n";
         ::write(socket, responseHeader, strlen(responseHeader));
-    });
+    }, 1);
 
     RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
 
index fb2f1ac..e156902 100644 (file)
@@ -230,7 +230,7 @@ TEST(WebKit, WKNavigationResponseDownloadAttribute)
                 "Content-Disposition: attachment; filename=fromHeader.txt;\r\n\r\n"
                 "Hello!"
             );
-        });
+        }, 1);
         auto delegate = adoptNS([NavigationResponseTestDelegate new]);
         auto webView = adoptNS([WKWebView new]);
         [webView setNavigationDelegate:delegate.get()];