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

Side by Side Diff: webrtc/p2p/base/transportdescriptionfactory.cc

Issue 1269843005: Added DtlsCertificate, a ref counted object owning an SSLIdentity (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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
11 #include "webrtc/p2p/base/transportdescriptionfactory.h" 11 #include "webrtc/p2p/base/transportdescriptionfactory.h"
12 12
13 #include "webrtc/p2p/base/transportdescription.h" 13 #include "webrtc/p2p/base/transportdescription.h"
14 #include "webrtc/base/helpers.h" 14 #include "webrtc/base/helpers.h"
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/base/messagedigest.h" 16 #include "webrtc/base/messagedigest.h"
17 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/base/sslfingerprint.h" 18 #include "webrtc/base/sslfingerprint.h"
19 19
20 namespace cricket { 20 namespace cricket {
21 21
22 static TransportProtocol kDefaultProtocol = ICEPROTO_RFC5245; 22 static TransportProtocol kDefaultProtocol = ICEPROTO_RFC5245;
23 23
24 TransportDescriptionFactory::TransportDescriptionFactory() 24 TransportDescriptionFactory::TransportDescriptionFactory()
25 : protocol_(kDefaultProtocol), 25 : protocol_(kDefaultProtocol),
26 secure_(SEC_DISABLED), 26 secure_(SEC_DISABLED),
27 identity_(NULL) { 27 certificate_(nullptr) {
28 } 28 }
29 29
30 TransportDescription* TransportDescriptionFactory::CreateOffer( 30 TransportDescription* TransportDescriptionFactory::CreateOffer(
31 const TransportOptions& options, 31 const TransportOptions& options,
32 const TransportDescription* current_description) const { 32 const TransportDescription* current_description) const {
33 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription()); 33 rtc::scoped_ptr<TransportDescription> desc(new TransportDescription());
34 34
35 // Set the transport type depending on the selected protocol. 35 // Set the transport type depending on the selected protocol.
36 if (protocol_ == ICEPROTO_RFC5245) { 36 if (protocol_ == ICEPROTO_RFC5245) {
37 desc->transport_type = NS_JINGLE_ICE_UDP; 37 desc->transport_type = NS_JINGLE_ICE_UDP;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 LOG(LS_WARNING) << "Failed to create TransportDescription answer " 122 LOG(LS_WARNING) << "Failed to create TransportDescription answer "
123 "because of incompatible security settings"; 123 "because of incompatible security settings";
124 return NULL; 124 return NULL;
125 } 125 }
126 126
127 return desc.release(); 127 return desc.release();
128 } 128 }
129 129
130 bool TransportDescriptionFactory::SetSecurityInfo( 130 bool TransportDescriptionFactory::SetSecurityInfo(
131 TransportDescription* desc, ConnectionRole role) const { 131 TransportDescription* desc, ConnectionRole role) const {
132 if (!identity_) { 132 if (!certificate_) {
133 LOG(LS_ERROR) << "Cannot create identity digest with no identity"; 133 LOG(LS_ERROR) << "Cannot create identity digest with no identity";
134 return false; 134 return false;
135 } 135 }
136 136
137 // This digest algorithm is used to produce the a=fingerprint lines in SDP. 137 // This digest algorithm is used to produce the a=fingerprint lines in SDP.
138 // RFC 4572 Section 5 requires that those lines use the same hash function as 138 // RFC 4572 Section 5 requires that those lines use the same hash function as
139 // the certificate's signature. 139 // the certificate's signature.
140 std::string digest_alg; 140 std::string digest_alg;
141 if (!identity_->certificate().GetSignatureDigestAlgorithm(&digest_alg)) { 141 if (!certificate_->identity()->certificate().GetSignatureDigestAlgorithm(
142 &digest_alg)) {
142 LOG(LS_ERROR) << "Failed to retrieve the certificate's digest algorithm"; 143 LOG(LS_ERROR) << "Failed to retrieve the certificate's digest algorithm";
143 return false; 144 return false;
144 } 145 }
145 146
146 desc->identity_fingerprint.reset( 147 desc->identity_fingerprint.reset(
147 rtc::SSLFingerprint::Create(digest_alg, identity_)); 148 rtc::SSLFingerprint::Create(digest_alg, certificate_->identity()));
148 if (!desc->identity_fingerprint.get()) { 149 if (!desc->identity_fingerprint.get()) {
149 LOG(LS_ERROR) << "Failed to create identity fingerprint, alg=" 150 LOG(LS_ERROR) << "Failed to create identity fingerprint, alg="
150 << digest_alg; 151 << digest_alg;
151 return false; 152 return false;
152 } 153 }
153 154
154 // Assign security role. 155 // Assign security role.
155 desc->connection_role = role; 156 desc->connection_role = role;
156 return true; 157 return true;
157 } 158 }
158 159
159 } // namespace cricket 160 } // namespace cricket
160 161
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698