OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/web/net/cert_host_pair.h" | 5 #include "ios/web/net/cert_host_pair.h" |
6 | 6 |
7 #include "net/cert/x509_certificate.h" | 7 #include "net/cert/x509_certificate.h" |
8 | 8 |
9 namespace web { | 9 namespace web { |
10 | 10 |
11 CertHostPair::CertHostPair(const scoped_refptr<net::X509Certificate>& cert, | 11 CertHostPair::CertHostPair(const scoped_refptr<net::X509Certificate>& cert, |
12 const std::string& host) | 12 const std::string& host) |
13 : cert(cert), host(host) {} | 13 : cert(cert), |
| 14 host(host), |
| 15 cert_hash(net::X509Certificate::CalculateChainFingerprint256( |
| 16 cert->os_cert_handle(), |
| 17 cert->GetIntermediateCertificates())) {} |
14 | 18 |
15 CertHostPair::CertHostPair(const CertHostPair& other) = default; | 19 CertHostPair::CertHostPair(const CertHostPair& other) = default; |
16 | 20 |
17 CertHostPair::~CertHostPair() {} | 21 CertHostPair::~CertHostPair() {} |
18 | 22 |
19 bool CertHostPair::operator<(const CertHostPair& other) const { | 23 bool CertHostPair::operator<(const CertHostPair& other) const { |
20 if (host != other.host) | 24 if (host != other.host) |
21 return host < other.host; | 25 return host < other.host; |
22 return net::X509Certificate::LessThan()(cert, other.cert); | 26 return net::SHA256HashValueLessThan()(cert_hash, other.cert_hash); |
23 } | 27 } |
24 | 28 |
25 } // web | 29 } // web |
OLD | NEW |