Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: talk/app/webrtc/test/fakedtlsidentitystore.h

Issue 1288033009: RTCCertificates added to RTCConfiguration, used by WebRtcSession/-DescriptionFactory (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed torbjorng's comment and merged with master Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/peerconnectioninterface.h ('k') | talk/app/webrtc/webrtcsession.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 14 matching lines...) Expand all
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28 #ifndef TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_ 28 #ifndef TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_
29 #define TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_ 29 #define TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_
30 30
31 #include <string> 31 #include <string>
32 32
33 #include "talk/app/webrtc/dtlsidentitystore.h" 33 #include "talk/app/webrtc/dtlsidentitystore.h"
34 #include "talk/app/webrtc/peerconnectioninterface.h" 34 #include "talk/app/webrtc/peerconnectioninterface.h"
35 #include "webrtc/base/rtccertificate.h"
35 36
36 static const char kRSA_PRIVATE_KEY_PEM[] = 37 static const char kRSA_PRIVATE_KEY_PEM[] =
37 "-----BEGIN RSA PRIVATE KEY-----\n" 38 "-----BEGIN RSA PRIVATE KEY-----\n"
38 "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMYRkbhmI7kVA/rM\n" 39 "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMYRkbhmI7kVA/rM\n"
39 "czsZ+6JDhDvnkF+vn6yCAGuRPV03zuRqZtDy4N4to7PZu9PjqrRl7nDMXrG3YG9y\n" 40 "czsZ+6JDhDvnkF+vn6yCAGuRPV03zuRqZtDy4N4to7PZu9PjqrRl7nDMXrG3YG9y\n"
40 "rlIAZ72KjcKKFAJxQyAKLCIdawKRyp8RdK3LEySWEZb0AV58IadqPZDTNHHRX8dz\n" 41 "rlIAZ72KjcKKFAJxQyAKLCIdawKRyp8RdK3LEySWEZb0AV58IadqPZDTNHHRX8dz\n"
41 "5aTSMsbbkZ+C/OzTnbiMqLL/vg6jAgMBAAECgYAvgOs4FJcgvp+TuREx7YtiYVsH\n" 42 "5aTSMsbbkZ+C/OzTnbiMqLL/vg6jAgMBAAECgYAvgOs4FJcgvp+TuREx7YtiYVsH\n"
42 "mwQPTum2z/8VzWGwR8BBHBvIpVe1MbD/Y4seyI2aco/7UaisatSgJhsU46/9Y4fq\n" 43 "mwQPTum2z/8VzWGwR8BBHBvIpVe1MbD/Y4seyI2aco/7UaisatSgJhsU46/9Y4fq\n"
43 "2TwXH9QANf4at4d9n/R6rzwpAJOpgwZgKvdQjkfrKTtgLV+/dawvpxUYkRH4JZM1\n" 44 "2TwXH9QANf4at4d9n/R6rzwpAJOpgwZgKvdQjkfrKTtgLV+/dawvpxUYkRH4JZM1\n"
44 "CVGukMfKNrSVH4Ap4QJBAOJmGV1ASPnB4r4nc99at7JuIJmd7fmuVUwUgYi4XgaR\n" 45 "CVGukMfKNrSVH4Ap4QJBAOJmGV1ASPnB4r4nc99at7JuIJmd7fmuVUwUgYi4XgaR\n"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>& 82 const rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>&
82 observer) override { 83 observer) override {
83 // TODO(hbos): Should be able to generate KT_ECDSA too. 84 // TODO(hbos): Should be able to generate KT_ECDSA too.
84 DCHECK(key_type == rtc::KT_RSA || should_fail_); 85 DCHECK(key_type == rtc::KT_RSA || should_fail_);
85 MessageData* msg = new MessageData( 86 MessageData* msg = new MessageData(
86 rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer)); 87 rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver>(observer));
87 rtc::Thread::Current()->Post( 88 rtc::Thread::Current()->Post(
88 this, should_fail_ ? MSG_FAILURE : MSG_SUCCESS, msg); 89 this, should_fail_ ? MSG_FAILURE : MSG_SUCCESS, msg);
89 } 90 }
90 91
92 static rtc::scoped_refptr<rtc::RTCCertificate> GenerateCertificate() {
93 std::string cert;
94 std::string key;
95 rtc::SSLIdentity::PemToDer("CERTIFICATE", kCERT_PEM, &cert);
96 rtc::SSLIdentity::PemToDer("RSA PRIVATE KEY", kRSA_PRIVATE_KEY_PEM, &key);
97
98 std::string pem_cert = rtc::SSLIdentity::DerToPem(
99 rtc::kPemTypeCertificate,
100 reinterpret_cast<const unsigned char*>(cert.data()),
101 cert.length());
102 std::string pem_key = rtc::SSLIdentity::DerToPem(
103 rtc::kPemTypeRsaPrivateKey,
104 reinterpret_cast<const unsigned char*>(key.data()),
105 key.length());
106 rtc::scoped_ptr<rtc::SSLIdentity> identity(
107 rtc::SSLIdentity::FromPEMStrings(pem_key, pem_cert));
108
109 return rtc::RTCCertificate::Create(identity.Pass());
110 }
111
91 private: 112 private:
92 enum { 113 enum {
93 MSG_SUCCESS, 114 MSG_SUCCESS,
94 MSG_FAILURE, 115 MSG_FAILURE,
95 }; 116 };
96 117
97 // rtc::MessageHandler implementation. 118 // rtc::MessageHandler implementation.
98 void OnMessage(rtc::Message* msg) { 119 void OnMessage(rtc::Message* msg) {
99 MessageData* message_data = static_cast<MessageData*>(msg->pdata); 120 MessageData* message_data = static_cast<MessageData*>(msg->pdata);
100 rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer = 121 rtc::scoped_refptr<webrtc::DtlsIdentityRequestObserver> observer =
(...skipping 12 matching lines...) Expand all
113 observer->OnFailure(0); 134 observer->OnFailure(0);
114 break; 135 break;
115 } 136 }
116 delete message_data; 137 delete message_data;
117 } 138 }
118 139
119 bool should_fail_; 140 bool should_fail_;
120 }; 141 };
121 142
122 #endif // TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_ 143 #endif // TALK_APP_WEBRTC_TEST_FAKEDTLSIDENTITYSERVICE_H_
OLDNEW
« no previous file with comments | « talk/app/webrtc/peerconnectioninterface.h ('k') | talk/app/webrtc/webrtcsession.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698