| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_SOCKET_DNS_CERT_PROVENANCE_CHECKER_H | 5 #ifndef NET_SOCKET_DNS_CERT_PROVENANCE_CHECKER_H |
| 6 #define NET_SOCKET_DNS_CERT_PROVENANCE_CHECKER_H | 6 #define NET_SOCKET_DNS_CERT_PROVENANCE_CHECKER_H |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 class DnsRRResolver; | 15 class DnsRRResolver; |
| 16 | 16 |
| 17 // DnsCertProvenanceChecker is an interface for asynchronously checking HTTPS | 17 // DnsCertProvenanceChecker is an interface for asynchronously checking HTTPS |
| 18 // certificates via a DNS side-channel. | 18 // certificates via a DNS side-channel. |
| 19 class DnsCertProvenanceChecker { | 19 class DnsCertProvenanceChecker { |
| 20 public: | 20 public: |
| 21 class Delegate { | 21 class Delegate { |
| 22 public: | 22 public: |
| 23 virtual ~Delegate(); | 23 virtual ~Delegate(); |
| 24 | 24 |
| 25 virtual void OnDnsCertLookupFailed( | 25 virtual void OnDnsCertLookupFailed( |
| 26 const std::string& hostname, | 26 const std::string& hostname, |
| 27 const std::vector<std::string>& der_certs) = 0; | 27 const std::vector<std::string>& der_certs) = 0; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 virtual ~DnsCertProvenanceChecker(); |
| 31 |
| 30 virtual void Shutdown() = 0; | 32 virtual void Shutdown() = 0; |
| 31 | 33 |
| 32 virtual ~DnsCertProvenanceChecker(); | |
| 33 | |
| 34 // DoAsyncVerification starts an asynchronous check for the given certificate | 34 // DoAsyncVerification starts an asynchronous check for the given certificate |
| 35 // chain. It must be run on the network thread. | 35 // chain. It must be run on the network thread. |
| 36 virtual void DoAsyncVerification( | 36 virtual void DoAsyncVerification( |
| 37 const std::string& hostname, | 37 const std::string& hostname, |
| 38 const std::vector<base::StringPiece>& der_certs) = 0; | 38 const std::vector<base::StringPiece>& der_certs) = 0; |
| 39 | 39 |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 // DoAsyncLookup performs a DNS lookup for the given name and certificate | 42 // DoAsyncLookup performs a DNS lookup for the given name and certificate |
| 43 // chain. In the event that the lookup reports a failure, the Delegate is | 43 // chain. In the event that the lookup reports a failure, the Delegate is |
| 44 // called back. | 44 // called back. |
| 45 static void DoAsyncLookup( | 45 static void DoAsyncLookup( |
| 46 const std::string& hostname, | 46 const std::string& hostname, |
| 47 const std::vector<base::StringPiece>& der_certs, | 47 const std::vector<base::StringPiece>& der_certs, |
| 48 DnsRRResolver* dnsrr_resolver, | 48 DnsRRResolver* dnsrr_resolver, |
| 49 Delegate* delegate); | 49 Delegate* delegate); |
| 50 | 50 |
| 51 // BuildEncryptedRecord encrypts the certificate chain to a fixed public key | 51 // BuildEncryptedRecord encrypts the certificate chain to a fixed public key |
| 52 // and returns the encrypted blob. Since this code is reporting a possible | 52 // and returns the encrypted blob. Since this code is reporting a possible |
| 53 // HTTPS failure, it would seem silly to use HTTPS to protect the uploaded | 53 // HTTPS failure, it would seem silly to use HTTPS to protect the uploaded |
| 54 // report. | 54 // report. |
| 55 static std::string BuildEncryptedReport( | 55 static std::string BuildEncryptedReport( |
| 56 const std::string& hostname, | 56 const std::string& hostname, |
| 57 const std::vector<std::string>& der_certs); | 57 const std::vector<std::string>& der_certs); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace net | 60 } // namespace net |
| 61 | 61 |
| 62 #endif // NET_SOCKET_DNS_CERT_PROVENANCE_CHECK_H | 62 #endif // NET_SOCKET_DNS_CERT_PROVENANCE_CHECK_H |
| OLD | NEW |