| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 server_ssl_->SetDtlsSrtpCryptoSuites(ciphers); | 467 server_ssl_->SetDtlsSrtpCryptoSuites(ciphers); |
| 468 } | 468 } |
| 469 | 469 |
| 470 bool GetDtlsSrtpCryptoSuite(bool client, int* retval) { | 470 bool GetDtlsSrtpCryptoSuite(bool client, int* retval) { |
| 471 if (client) | 471 if (client) |
| 472 return client_ssl_->GetDtlsSrtpCryptoSuite(retval); | 472 return client_ssl_->GetDtlsSrtpCryptoSuite(retval); |
| 473 else | 473 else |
| 474 return server_ssl_->GetDtlsSrtpCryptoSuite(retval); | 474 return server_ssl_->GetDtlsSrtpCryptoSuite(retval); |
| 475 } | 475 } |
| 476 | 476 |
| 477 bool GetPeerCertificate(bool client, rtc::SSLCertificate** cert) { | 477 rtc::scoped_ptr<rtc::SSLCertificate> GetPeerCertificate(bool client) { |
| 478 if (client) | 478 if (client) |
| 479 return client_ssl_->GetPeerCertificate(cert); | 479 return client_ssl_->GetPeerCertificate(); |
| 480 else | 480 else |
| 481 return server_ssl_->GetPeerCertificate(cert); | 481 return server_ssl_->GetPeerCertificate(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 bool GetSslCipherSuite(bool client, int* retval) { | 484 bool GetSslCipherSuite(bool client, int* retval) { |
| 485 if (client) | 485 if (client) |
| 486 return client_ssl_->GetSslCipherSuite(retval); | 486 return client_ssl_->GetSslCipherSuite(retval); |
| 487 else | 487 else |
| 488 return server_ssl_->GetSslCipherSuite(retval); | 488 return server_ssl_->GetSslCipherSuite(retval); |
| 489 } | 489 } |
| 490 | 490 |
| 491 int GetSslVersion(bool client) { | 491 int GetSslVersion(bool client) { |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 MAYBE_SKIP_TEST(HaveDtls); | 1030 MAYBE_SKIP_TEST(HaveDtls); |
| 1031 TestHandshake(); | 1031 TestHandshake(); |
| 1032 TestTransfer(100); | 1032 TestTransfer(100); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 // Test getting the remote certificate. | 1035 // Test getting the remote certificate. |
| 1036 TEST_F(SSLStreamAdapterTestDTLSFromPEMStrings, TestDTLSGetPeerCertificate) { | 1036 TEST_F(SSLStreamAdapterTestDTLSFromPEMStrings, TestDTLSGetPeerCertificate) { |
| 1037 MAYBE_SKIP_TEST(HaveDtls); | 1037 MAYBE_SKIP_TEST(HaveDtls); |
| 1038 | 1038 |
| 1039 // Peer certificates haven't been received yet. | 1039 // Peer certificates haven't been received yet. |
| 1040 rtc::scoped_ptr<rtc::SSLCertificate> client_peer_cert; | 1040 ASSERT_FALSE(GetPeerCertificate(true)); |
| 1041 ASSERT_FALSE(GetPeerCertificate(true, client_peer_cert.accept())); | 1041 ASSERT_FALSE(GetPeerCertificate(false)); |
| 1042 ASSERT_FALSE(client_peer_cert != NULL); | |
| 1043 | |
| 1044 rtc::scoped_ptr<rtc::SSLCertificate> server_peer_cert; | |
| 1045 ASSERT_FALSE(GetPeerCertificate(false, server_peer_cert.accept())); | |
| 1046 ASSERT_FALSE(server_peer_cert != NULL); | |
| 1047 | 1042 |
| 1048 TestHandshake(); | 1043 TestHandshake(); |
| 1049 | 1044 |
| 1050 // The client should have a peer certificate after the handshake. | 1045 // The client should have a peer certificate after the handshake. |
| 1051 ASSERT_TRUE(GetPeerCertificate(true, client_peer_cert.accept())); | 1046 rtc::scoped_ptr<rtc::SSLCertificate> client_peer_cert = |
| 1052 ASSERT_TRUE(client_peer_cert != NULL); | 1047 GetPeerCertificate(true); |
| 1048 ASSERT_TRUE(client_peer_cert); |
| 1053 | 1049 |
| 1054 // It's not kCERT_PEM. | 1050 // It's not kCERT_PEM. |
| 1055 std::string client_peer_string = client_peer_cert->ToPEMString(); | 1051 std::string client_peer_string = client_peer_cert->ToPEMString(); |
| 1056 ASSERT_NE(kCERT_PEM, client_peer_string); | 1052 ASSERT_NE(kCERT_PEM, client_peer_string); |
| 1057 | 1053 |
| 1058 // It must not have a chain, because the test certs are self-signed. | 1054 // It must not have a chain, because the test certs are self-signed. |
| 1059 ASSERT_FALSE(client_peer_cert->GetChain()); | 1055 ASSERT_FALSE(client_peer_cert->GetChain()); |
| 1060 | 1056 |
| 1061 // The server should have a peer certificate after the handshake. | 1057 // The server should have a peer certificate after the handshake. |
| 1062 ASSERT_TRUE(GetPeerCertificate(false, server_peer_cert.accept())); | 1058 rtc::scoped_ptr<rtc::SSLCertificate> server_peer_cert = |
| 1063 ASSERT_TRUE(server_peer_cert != NULL); | 1059 GetPeerCertificate(false); |
| 1060 ASSERT_TRUE(server_peer_cert); |
| 1064 | 1061 |
| 1065 // It's kCERT_PEM | 1062 // It's kCERT_PEM |
| 1066 ASSERT_EQ(kCERT_PEM, server_peer_cert->ToPEMString()); | 1063 ASSERT_EQ(kCERT_PEM, server_peer_cert->ToPEMString()); |
| 1067 | 1064 |
| 1068 // It must not have a chain, because the test certs are self-signed. | 1065 // It must not have a chain, because the test certs are self-signed. |
| 1069 ASSERT_FALSE(server_peer_cert->GetChain()); | 1066 ASSERT_FALSE(server_peer_cert->GetChain()); |
| 1070 } | 1067 } |
| 1071 | 1068 |
| 1072 // Test getting the used DTLS ciphers. | 1069 // Test getting the used DTLS ciphers. |
| 1073 // DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used. | 1070 // DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); | 1158 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); |
| 1162 INSTANTIATE_TEST_CASE_P( | 1159 INSTANTIATE_TEST_CASE_P( |
| 1163 SSLStreamAdapterTestsDTLS, | 1160 SSLStreamAdapterTestsDTLS, |
| 1164 SSLStreamAdapterTestDTLS, | 1161 SSLStreamAdapterTestDTLS, |
| 1165 Combine(Values(rtc::KeyParams::RSA(1024, 65537), | 1162 Combine(Values(rtc::KeyParams::RSA(1024, 65537), |
| 1166 rtc::KeyParams::RSA(1152, 65537), | 1163 rtc::KeyParams::RSA(1152, 65537), |
| 1167 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), | 1164 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), |
| 1168 Values(rtc::KeyParams::RSA(1024, 65537), | 1165 Values(rtc::KeyParams::RSA(1024, 65537), |
| 1169 rtc::KeyParams::RSA(1152, 65537), | 1166 rtc::KeyParams::RSA(1152, 65537), |
| 1170 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); | 1167 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); |
| OLD | NEW |