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

Unified Diff: webrtc/base/sslidentity.h

Issue 1683193003: Implement certificate lifetime parameter as required by WebRTC RFC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address feedback Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/base/sslidentity.h
diff --git a/webrtc/base/sslidentity.h b/webrtc/base/sslidentity.h
index a143ee4108bc4585174e2a19838133273751a5d9..0f81929cc4e42e20af91ce9c731df706c1fa9715 100644
--- a/webrtc/base/sslidentity.h
+++ b/webrtc/base/sslidentity.h
@@ -36,7 +36,7 @@ class SSLCertChain;
// possibly caching of intermediate results.)
class SSLCertificate {
public:
- // Parses and build a certificate from a PEM encoded string.
+ // Parses and builds a certificate from a PEM encoded string.
// Returns NULL on failure.
// The length of the string representation of the certificate is
// stored in *pem_length if it is non-NULL, and only if
@@ -125,6 +125,12 @@ static const int kRsaDefaultExponent = 0x10001; // = 2^16+1 = 65537
static const int kRsaMinModSize = 1024;
static const int kRsaMaxModSize = 8192;
+// Certificate default validity lifetime.
+static const int kDefaultCertificateLifetime = 60 * 60 * 24 * 30; // 30 days
+// Certificate validity window.
+// This is to compensate for slightly incorrect system clocks.
+static const int kCertificateWindow = -60 * 60 * 24;
Ryan Sleevi 2016/03/08 17:04:43 Explain the units this is in (seconds?) Explain wh
torbjorng (webrtc) 2016/03/30 14:00:29 Like all things in x509, this is seconds. I agree
Ryan Sleevi 2016/03/31 02:07:53 I'm not sure what you meant, but X.509 is based on
torbjorng (webrtc) 2016/03/31 13:18:34 Really? The ANS1_TIME type used therein explicitly
+
struct RSAParams {
unsigned int mod_size;
unsigned int pub_exp;
@@ -184,18 +190,28 @@ struct SSLIdentityParams {
class SSLIdentity {
public:
// Generates an identity (keypair and self-signed certificate). If
- // common_name is non-empty, it will be used for the certificate's
- // subject and issuer name, otherwise a random string will be used.
+ // |common_name| is non-empty, it will be used for the certificate's subject
+ // and issuer name, otherwise a random string will be used. The key type and
+ // parameters are defined in |key_param|. The certificate's lifetime in
+ // seconds from the current time is defined in |certificate_lifetime|; it
+ // should be a non-negative number.
// Returns NULL on failure.
// Caller is responsible for freeing the returned object.
static SSLIdentity* Generate(const std::string& common_name,
Ryan Sleevi 2016/03/08 17:04:43 Per Google style guide on overloading, this would
torbjorng (webrtc) 2016/03/30 14:00:29 I'm fixing this in a follow-up CL.
- const KeyParams& key_param);
+ const KeyParams& key_param,
+ time_t certificate_lifetime);
+ static SSLIdentity* Generate(const std::string& common_name,
+ const KeyParams& key_param) {
+ return Generate(common_name, key_param, kDefaultCertificateLifetime);
+ }
static SSLIdentity* Generate(const std::string& common_name,
KeyType key_type) {
return Generate(common_name, KeyParams(key_type));
}
// Generates an identity with the specified validity period.
+ // TODO(torbjorng): Now that Generate() accepts relevant params, make tests
+ // use that instead of this function.
static SSLIdentity* GenerateForTest(const SSLIdentityParams& params);
// Construct an identity from a private key and a certificate.

Powered by Google App Engine
This is Rietveld 408576698