OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/media/webrtc_identity_store.h" | 5 #include "content/browser/media/webrtc_identity_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 }; | 32 }; |
33 | 33 |
34 // Generates a new identity using |common_name| which expires after | 34 // Generates a new identity using |common_name| which expires after |
35 // |validity_period| and returns the result in |result|. | 35 // |validity_period| and returns the result in |result|. |
36 static void GenerateIdentityWorker(const std::string& common_name, | 36 static void GenerateIdentityWorker(const std::string& common_name, |
37 base::TimeDelta validity_period, | 37 base::TimeDelta validity_period, |
38 WebRTCIdentityRequestResult* result) { | 38 WebRTCIdentityRequestResult* result) { |
39 result->error = net::OK; | 39 result->error = net::OK; |
40 int serial_number = base::RandInt(0, std::numeric_limits<int>::max()); | 40 int serial_number = base::RandInt(0, std::numeric_limits<int>::max()); |
41 | 41 |
42 scoped_ptr<crypto::RSAPrivateKey> key(crypto::RSAPrivateKey::Create(1024)); | 42 scoped_ptr<crypto::RSAPrivateKey> key; |
43 if (!key.get()) { | 43 base::Time now = base::Time::Now(); |
44 DLOG(ERROR) << "Unable to create key pair for client"; | 44 bool success = net::x509_util::CreateKeyAndSelfSignedCert( |
Ami GONE FROM CHROMIUM
2013/10/30 19:21:57
Does this CL change what used to be signed with SH
bemasc
2013/10/30 19:30:49
This CL is intended not to re-sign any old keys us
| |
45 result->error = net::ERR_KEY_GENERATION_FAILED; | 45 "CN=" + common_name, |
46 return; | 46 serial_number, |
47 } | 47 now, |
48 now + validity_period, | |
49 &key, | |
50 &result->certificate); | |
48 | 51 |
49 base::Time now = base::Time::Now(); | |
50 bool success = net::x509_util::CreateSelfSignedCert(key.get(), | |
51 "CN=" + common_name, | |
52 serial_number, | |
53 now, | |
54 now + validity_period, | |
55 &result->certificate); | |
56 if (!success) { | 52 if (!success) { |
57 DLOG(ERROR) << "Unable to create x509 cert for client"; | 53 DLOG(ERROR) << "Unable to create x509 cert for client"; |
58 result->error = net::ERR_SELF_SIGNED_CERT_GENERATION_FAILED; | 54 result->error = net::ERR_SELF_SIGNED_CERT_GENERATION_FAILED; |
59 return; | 55 return; |
60 } | 56 } |
61 | 57 |
62 std::vector<uint8> private_key_info; | 58 std::vector<uint8> private_key_info; |
63 if (!key->ExportPrivateKey(&private_key_info)) { | 59 if (!key->ExportPrivateKey(&private_key_info)) { |
64 DLOG(ERROR) << "Unable to export private key"; | 60 DLOG(ERROR) << "Unable to export private key"; |
65 result->error = net::ERR_PRIVATE_KEY_EXPORT_FAILED; | 61 result->error = net::ERR_PRIVATE_KEY_EXPORT_FAILED; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 if (in_flight_requests_[i]->origin_ == origin && | 306 if (in_flight_requests_[i]->origin_ == origin && |
311 in_flight_requests_[i]->identity_name_ == identity_name && | 307 in_flight_requests_[i]->identity_name_ == identity_name && |
312 in_flight_requests_[i]->common_name_ == common_name) { | 308 in_flight_requests_[i]->common_name_ == common_name) { |
313 return in_flight_requests_[i]; | 309 return in_flight_requests_[i]; |
314 } | 310 } |
315 } | 311 } |
316 return NULL; | 312 return NULL; |
317 } | 313 } |
318 | 314 |
319 } // namespace content | 315 } // namespace content |
OLD | NEW |