OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 OpenSSLCertificate* certificate = | 400 OpenSSLCertificate* certificate = |
401 OpenSSLCertificate::Generate(key_pair, params); | 401 OpenSSLCertificate::Generate(key_pair, params); |
402 if (certificate) | 402 if (certificate) |
403 return new OpenSSLIdentity(key_pair, certificate); | 403 return new OpenSSLIdentity(key_pair, certificate); |
404 delete key_pair; | 404 delete key_pair; |
405 } | 405 } |
406 LOG(LS_INFO) << "Identity generation failed"; | 406 LOG(LS_INFO) << "Identity generation failed"; |
407 return NULL; | 407 return NULL; |
408 } | 408 } |
409 | 409 |
410 OpenSSLIdentity* OpenSSLIdentity::Generate(const std::string& common_name, | 410 OpenSSLIdentity* OpenSSLIdentity::GenerateWithExpiration( |
411 const KeyParams& key_params, | 411 const std::string& common_name, |
412 time_t certificate_lifetime) { | 412 const KeyParams& key_params, |
413 time_t certificate_lifetime) { | |
413 SSLIdentityParams params; | 414 SSLIdentityParams params; |
414 params.key_params = key_params; | 415 params.key_params = key_params; |
415 params.common_name = common_name; | 416 params.common_name = common_name; |
416 time_t now = time(NULL); | 417 time_t now = time(NULL); |
417 params.not_before = now + kCertificateWindow; | 418 params.not_before = now + kCertificateWindowInSeconds; |
418 params.not_after = now + certificate_lifetime; | 419 params.not_after = now + certificate_lifetime; |
419 RTC_DCHECK(params.not_before < params.not_after); | 420 if (params.not_before > params.not_after) |
421 return nullptr; | |
perkj_webrtc
2016/03/31 13:01:41
RTC_CHECK(... ) ?
torbjorng (webrtc)
2016/03/31 13:58:18
I removed the RTC_CHECK here since it would not be
| |
420 return GenerateInternal(params); | 422 return GenerateInternal(params); |
421 } | 423 } |
422 | 424 |
423 OpenSSLIdentity* OpenSSLIdentity::GenerateForTest( | 425 OpenSSLIdentity* OpenSSLIdentity::GenerateForTest( |
424 const SSLIdentityParams& params) { | 426 const SSLIdentityParams& params) { |
425 return GenerateInternal(params); | 427 return GenerateInternal(params); |
426 } | 428 } |
427 | 429 |
428 SSLIdentity* OpenSSLIdentity::FromPEMStrings( | 430 SSLIdentity* OpenSSLIdentity::FromPEMStrings( |
429 const std::string& private_key, | 431 const std::string& private_key, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 SSL_CTX_use_PrivateKey(ctx, key_pair_->pkey()) != 1) { | 471 SSL_CTX_use_PrivateKey(ctx, key_pair_->pkey()) != 1) { |
470 LogSSLErrors("Configuring key and certificate"); | 472 LogSSLErrors("Configuring key and certificate"); |
471 return false; | 473 return false; |
472 } | 474 } |
473 return true; | 475 return true; |
474 } | 476 } |
475 | 477 |
476 } // namespace rtc | 478 } // namespace rtc |
477 | 479 |
478 #endif // HAVE_OPENSSL_SSL_H | 480 #endif // HAVE_OPENSSL_SSL_H |
OLD | NEW |