Commit b00da14f authored by David Benjamin's avatar David Benjamin Committed by Commit Bot

Make SSLInfo::Reset less error-prone.

Take advantage of inline member initializers, which are harder to
forget, and operator=, which the compiler generates for us.

Bug: none
Change-Id: I6658cab836444ea74ae237fe3c065edebc400615
Reviewed-on: https://chromium-review.googlesource.com/1003553Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Commit-Queue: David Benjamin <davidben@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549567}
parent 26a1fcd6
...@@ -4,52 +4,20 @@ ...@@ -4,52 +4,20 @@
#include "net/ssl/ssl_info.h" #include "net/ssl/ssl_info.h"
#include "base/pickle.h"
#include "base/stl_util.h"
#include "net/cert/cert_status_flags.h"
#include "net/cert/ct_policy_status.h"
#include "net/cert/signed_certificate_timestamp.h"
#include "net/cert/x509_certificate.h" #include "net/cert/x509_certificate.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "third_party/boringssl/src/include/openssl/ssl.h"
namespace net { namespace net {
SSLInfo::SSLInfo() { SSLInfo::SSLInfo() = default;
Reset();
}
SSLInfo::SSLInfo(const SSLInfo& info) { SSLInfo::SSLInfo(const SSLInfo& info) = default;
*this = info;
}
SSLInfo::~SSLInfo() = default; SSLInfo::~SSLInfo() = default;
SSLInfo& SSLInfo::operator=(const SSLInfo& info) = default; SSLInfo& SSLInfo::operator=(const SSLInfo& info) = default;
void SSLInfo::Reset() { void SSLInfo::Reset() {
cert = NULL; *this = SSLInfo();
unverified_cert = NULL;
cert_status = 0;
security_bits = -1;
key_exchange_group = 0;
connection_status = 0;
is_issued_by_known_root = false;
pkp_bypassed = false;
client_cert_sent = false;
channel_id_sent = false;
token_binding_negotiated = false;
token_binding_key_param = TB_PARAM_ECDSAP256;
dummy_pq_padding_received = false;
handshake_type = HANDSHAKE_UNKNOWN;
base::STLClearObject(&public_key_hashes);
base::STLClearObject(&pinning_failure_log);
base::STLClearObject(&signed_certificate_timestamps);
ct_policy_compliance =
ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE;
ct_policy_compliance_required = false;
ocsp_result = OCSPVerifyResult();
is_fatal_cert_error = false;
} }
void SSLInfo::SetCertError(int error) { void SSLInfo::SetCertError(int error) {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "net/base/net_export.h" #include "net/base/net_export.h"
#include "net/cert/cert_status_flags.h" #include "net/cert/cert_status_flags.h"
#include "net/cert/ct_policy_status.h"
#include "net/cert/ct_verify_result.h" #include "net/cert/ct_verify_result.h"
#include "net/cert/ocsp_verify_result.h" #include "net/cert/ocsp_verify_result.h"
#include "net/cert/sct_status_flags.h" #include "net/cert/sct_status_flags.h"
...@@ -21,12 +22,6 @@ ...@@ -21,12 +22,6 @@
namespace net { namespace net {
namespace ct {
enum class CTPolicyCompliance;
} // namespace ct
class X509Certificate; class X509Certificate;
// SSL connection info. // SSL connection info.
...@@ -74,51 +69,51 @@ class NET_EXPORT SSLInfo { ...@@ -74,51 +69,51 @@ class NET_EXPORT SSLInfo {
// Bitmask of status info of |cert|, representing, for example, known errors // Bitmask of status info of |cert|, representing, for example, known errors
// and extended validation (EV) status. // and extended validation (EV) status.
// See cert_status_flags.h for values. // See cert_status_flags.h for values.
CertStatus cert_status; CertStatus cert_status = 0;
// The security strength, in bits, of the SSL cipher suite. // The security strength, in bits, of the SSL cipher suite.
// 0 means the connection is not encrypted. // 0 means the connection is not encrypted.
// -1 means the security strength is unknown. // -1 means the security strength is unknown.
int security_bits; int security_bits = -1;
// The ID of the (EC)DH group used by the key exchange or zero if unknown // The ID of the (EC)DH group used by the key exchange or zero if unknown
// (older cache entries may not store the value) or not applicable. // (older cache entries may not store the value) or not applicable.
uint16_t key_exchange_group; uint16_t key_exchange_group = 0;
// Information about the SSL connection itself. See // Information about the SSL connection itself. See
// ssl_connection_status_flags.h for values. The protocol version, // ssl_connection_status_flags.h for values. The protocol version,
// ciphersuite, and compression in use are encoded within. // ciphersuite, and compression in use are encoded within.
int connection_status; int connection_status = 0;
// If the certificate is valid, then this is true iff it was rooted at a // If the certificate is valid, then this is true iff it was rooted at a
// standard CA root. (As opposed to a user-installed root.) // standard CA root. (As opposed to a user-installed root.)
bool is_issued_by_known_root; bool is_issued_by_known_root = false;
// True if pinning was bypassed on this connection. // True if pinning was bypassed on this connection.
bool pkp_bypassed; bool pkp_bypassed = false;
// True if a client certificate was sent to the server. Note that sending // True if a client certificate was sent to the server. Note that sending
// a Certificate message with no client certificate in it does not count. // a Certificate message with no client certificate in it does not count.
bool client_cert_sent; bool client_cert_sent = false;
// True if a channel ID was sent to the server. // True if a channel ID was sent to the server.
bool channel_id_sent; bool channel_id_sent = false;
// True if Token Binding was negotiated with the server and we agreed on a // True if Token Binding was negotiated with the server and we agreed on a
// version and key params. // version and key params.
bool token_binding_negotiated; bool token_binding_negotiated = false;
// Only valid if |token_binding_negotiated| is true. Contains the key param // Only valid if |token_binding_negotiated| is true. Contains the key param
// negotiated by the client and server in the Token Binding Negotiation TLS // negotiated by the client and server in the Token Binding Negotiation TLS
// extension. // extension.
TokenBindingParam token_binding_key_param; TokenBindingParam token_binding_key_param = TB_PARAM_ECDSAP256;
// True if the server echoed a dummy post-quantum padding extension. See // True if the server echoed a dummy post-quantum padding extension. See
// https://crbug.com/801302. // https://crbug.com/801302.
// TODO(agl): remove by 2018-05-31. // TODO(agl): remove by 2018-05-31.
bool dummy_pq_padding_received; bool dummy_pq_padding_received = false;
HandshakeType handshake_type; HandshakeType handshake_type = HANDSHAKE_UNKNOWN;
// The hashes, in several algorithms, of the SubjectPublicKeyInfos from // The hashes, in several algorithms, of the SubjectPublicKeyInfos from
// each certificate in the chain. // each certificate in the chain.
...@@ -135,19 +130,20 @@ class NET_EXPORT SSLInfo { ...@@ -135,19 +130,20 @@ class NET_EXPORT SSLInfo {
// Whether the connection complied with the CT cert policy, and if // Whether the connection complied with the CT cert policy, and if
// not, why not. // not, why not.
ct::CTPolicyCompliance ct_policy_compliance; ct::CTPolicyCompliance ct_policy_compliance =
ct::CTPolicyCompliance::CT_POLICY_COMPLIANCE_DETAILS_NOT_AVAILABLE;
// True if the connection was required to comply with the CT cert policy. Only // True if the connection was required to comply with the CT cert policy. Only
// meaningful if |ct_policy_compliance| is not // meaningful if |ct_policy_compliance| is not
// COMPLIANCE_DETAILS_NOT_AVAILABLE. // COMPLIANCE_DETAILS_NOT_AVAILABLE.
bool ct_policy_compliance_required; bool ct_policy_compliance_required = false;
// OCSP stapling details. // OCSP stapling details.
OCSPVerifyResult ocsp_result; OCSPVerifyResult ocsp_result;
// True if there was a certificate error which should be treated as fatal, // True if there was a certificate error which should be treated as fatal,
// and false otherwise. // and false otherwise.
bool is_fatal_cert_error; bool is_fatal_cert_error = false;
}; };
} // namespace net } // namespace net
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment