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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; | 848 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; |
849 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert1; | 849 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert1; |
850 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert2; | 850 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert2; |
851 | 851 |
852 // After negotiation, each side has a distinct local certificate, but still no | 852 // After negotiation, each side has a distinct local certificate, but still no |
853 // remote certificate, because connection has not yet occurred. | 853 // remote certificate, because connection has not yet occurred. |
854 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); | 854 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); |
855 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); | 855 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); |
856 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), | 856 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), |
857 certificate2->ssl_certificate().ToPEMString()); | 857 certificate2->ssl_certificate().ToPEMString()); |
858 ASSERT_FALSE( | 858 ASSERT_FALSE(client1_.transport()->GetRemoteSSLCertificate()); |
859 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept())); | 859 ASSERT_FALSE(client2_.transport()->GetRemoteSSLCertificate()); |
860 ASSERT_FALSE(remote_cert1 != NULL); | |
861 ASSERT_FALSE( | |
862 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept())); | |
863 ASSERT_FALSE(remote_cert2 != NULL); | |
864 } | 860 } |
865 | 861 |
866 // Test Certificates state after connection. | 862 // Test Certificates state after connection. |
867 TEST_F(DtlsTransportChannelTest, TestCertificatesAfterConnect) { | 863 TEST_F(DtlsTransportChannelTest, TestCertificatesAfterConnect) { |
868 MAYBE_SKIP_TEST(HaveDtls); | 864 MAYBE_SKIP_TEST(HaveDtls); |
869 PrepareDtls(true, true, rtc::KT_DEFAULT); | 865 PrepareDtls(true, true, rtc::KT_DEFAULT); |
870 ASSERT_TRUE(Connect()); | 866 ASSERT_TRUE(Connect()); |
871 | 867 |
872 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; | 868 rtc::scoped_refptr<rtc::RTCCertificate> certificate1; |
873 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; | 869 rtc::scoped_refptr<rtc::RTCCertificate> certificate2; |
874 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert1; | |
875 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert2; | |
876 | 870 |
877 // After connection, each side has a distinct local certificate. | 871 // After connection, each side has a distinct local certificate. |
878 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); | 872 ASSERT_TRUE(client1_.transport()->GetLocalCertificate(&certificate1)); |
879 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); | 873 ASSERT_TRUE(client2_.transport()->GetLocalCertificate(&certificate2)); |
880 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), | 874 ASSERT_NE(certificate1->ssl_certificate().ToPEMString(), |
881 certificate2->ssl_certificate().ToPEMString()); | 875 certificate2->ssl_certificate().ToPEMString()); |
882 | 876 |
883 // Each side's remote certificate is the other side's local certificate. | 877 // Each side's remote certificate is the other side's local certificate. |
884 ASSERT_TRUE( | 878 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert1 = |
885 client1_.transport()->GetRemoteSSLCertificate(remote_cert1.accept())); | 879 client1_.transport()->GetRemoteSSLCertificate(); |
| 880 ASSERT_TRUE(remote_cert1); |
886 ASSERT_EQ(remote_cert1->ToPEMString(), | 881 ASSERT_EQ(remote_cert1->ToPEMString(), |
887 certificate2->ssl_certificate().ToPEMString()); | 882 certificate2->ssl_certificate().ToPEMString()); |
888 ASSERT_TRUE( | 883 rtc::scoped_ptr<rtc::SSLCertificate> remote_cert2 = |
889 client2_.transport()->GetRemoteSSLCertificate(remote_cert2.accept())); | 884 client2_.transport()->GetRemoteSSLCertificate(); |
| 885 ASSERT_TRUE(remote_cert2); |
890 ASSERT_EQ(remote_cert2->ToPEMString(), | 886 ASSERT_EQ(remote_cert2->ToPEMString(), |
891 certificate1->ssl_certificate().ToPEMString()); | 887 certificate1->ssl_certificate().ToPEMString()); |
892 } | 888 } |
OLD | NEW |