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_SSL_HOST_INFO_H_ | 5 #ifndef NET_SOCKET_SSL_HOST_INFO_H_ |
6 #define NET_SOCKET_SSL_HOST_INFO_H_ | 6 #define NET_SOCKET_SSL_HOST_INFO_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "net/base/cert_verifier.h" | 14 #include "net/base/cert_verifier.h" |
15 #include "net/base/cert_verify_result.h" | 15 #include "net/base/cert_verify_result.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/base/dnsrr_resolver.h" |
17 #include "net/socket/ssl_client_socket.h" | 18 #include "net/socket/ssl_client_socket.h" |
18 | 19 |
19 namespace net { | 20 namespace net { |
20 | 21 |
21 class X509Certificate; | 22 class X509Certificate; |
22 struct SSLConfig; | 23 struct SSLConfig; |
23 | 24 |
24 // SSLHostInfo is an interface for fetching information about an SSL server. | 25 // SSLHostInfo is an interface for fetching information about an SSL server. |
25 // This information may be stored on disk so does not include keys or session | 26 // This information may be stored on disk so does not include keys or session |
26 // information etc. Primarily it's intended for caching the server's | 27 // information etc. Primarily it's intended for caching the server's |
(...skipping 22 matching lines...) Expand all Loading... |
49 // but, obviously, a callback will never be made. | 50 // but, obviously, a callback will never be made. |
50 virtual int WaitForDataReady(CompletionCallback* callback) = 0; | 51 virtual int WaitForDataReady(CompletionCallback* callback) = 0; |
51 | 52 |
52 // Persist allows for the host information to be updated for future users. | 53 // Persist allows for the host information to be updated for future users. |
53 // This is a fire and forget operation: the caller may drop its reference | 54 // This is a fire and forget operation: the caller may drop its reference |
54 // from this object and the store operation will still complete. This can | 55 // from this object and the store operation will still complete. This can |
55 // only be called once WaitForDataReady has returned OK or called its | 56 // only be called once WaitForDataReady has returned OK or called its |
56 // callback. | 57 // callback. |
57 virtual void Persist() = 0; | 58 virtual void Persist() = 0; |
58 | 59 |
| 60 // StartDnsLookup triggers a DNS lookup for the host. |
| 61 void StartDnsLookup(DnsRRResolver* dnsrr_resolver); |
| 62 |
59 struct State { | 63 struct State { |
60 State(); | 64 State(); |
61 ~State(); | 65 ~State(); |
62 | 66 |
63 void Clear(); | 67 void Clear(); |
64 | 68 |
65 // certs is a vector of DER encoded X.509 certificates, as the server | 69 // certs is a vector of DER encoded X.509 certificates, as the server |
66 // returned them and in the same order. | 70 // returned them and in the same order. |
67 std::vector<std::string> certs; | 71 std::vector<std::string> certs; |
68 // server_hello contains the bytes of the ServerHello message (or may be | 72 // server_hello contains the bytes of the ServerHello message (or may be |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bool cert_verification_complete_; | 116 bool cert_verification_complete_; |
113 int cert_verification_error_; | 117 int cert_verification_error_; |
114 | 118 |
115 private: | 119 private: |
116 // This is the callback function which the CertVerifier calls via |callback_|. | 120 // This is the callback function which the CertVerifier calls via |callback_|. |
117 void VerifyCallback(int rv); | 121 void VerifyCallback(int rv); |
118 | 122 |
119 // ParseInner is a helper function for Parse. | 123 // ParseInner is a helper function for Parse. |
120 bool ParseInner(const std::string& data); | 124 bool ParseInner(const std::string& data); |
121 | 125 |
| 126 // DnsComplete is a callback function which is called when our DNS resolution |
| 127 // completes. |
| 128 void DnsComplete(int rv); |
| 129 |
122 // This is the hostname that we'll validate the certificates against. | 130 // This is the hostname that we'll validate the certificates against. |
123 const std::string hostname_; | 131 const std::string hostname_; |
124 bool cert_parsing_failed_; | 132 bool cert_parsing_failed_; |
125 CompletionCallback* cert_verification_callback_; | 133 CompletionCallback* cert_verification_callback_; |
126 // These two members are taken from the SSLConfig. | 134 // These two members are taken from the SSLConfig. |
127 bool rev_checking_enabled_; | 135 bool rev_checking_enabled_; |
128 bool verify_ev_cert_; | 136 bool verify_ev_cert_; |
129 base::TimeTicks verification_start_time_; | 137 base::TimeTicks verification_start_time_; |
130 base::TimeTicks verification_end_time_; | 138 base::TimeTicks verification_end_time_; |
131 CertVerifyResult cert_verify_result_; | 139 CertVerifyResult cert_verify_result_; |
132 SingleRequestCertVerifier verifier_; | 140 SingleRequestCertVerifier verifier_; |
133 scoped_refptr<X509Certificate> cert_; | 141 scoped_refptr<X509Certificate> cert_; |
134 scoped_refptr<CancelableCompletionCallback<SSLHostInfo> > callback_; | 142 scoped_refptr<CancelableCompletionCallback<SSLHostInfo> > callback_; |
| 143 |
| 144 DnsRRResolver* dnsrr_resolver_; |
| 145 CompletionCallback* dns_callback_; |
| 146 DnsRRResolver::Handle dns_handle_; |
| 147 RRResponse dns_response_; |
| 148 base::TimeTicks dns_lookup_start_time_; |
135 }; | 149 }; |
136 | 150 |
137 class SSLHostInfoFactory { | 151 class SSLHostInfoFactory { |
138 public: | 152 public: |
139 virtual ~SSLHostInfoFactory(); | 153 virtual ~SSLHostInfoFactory(); |
140 | 154 |
141 // GetForHost returns a fresh, allocated SSLHostInfo for the given hostname | 155 // GetForHost returns a fresh, allocated SSLHostInfo for the given hostname |
142 // or NULL on failure. | 156 // or NULL on failure. |
143 virtual SSLHostInfo* GetForHost(const std::string& hostname, | 157 virtual SSLHostInfo* GetForHost(const std::string& hostname, |
144 const SSLConfig& ssl_config) = 0; | 158 const SSLConfig& ssl_config) = 0; |
145 }; | 159 }; |
146 | 160 |
147 } // namespace net | 161 } // namespace net |
148 | 162 |
149 #endif // NET_SOCKET_SSL_HOST_INFO_H_ | 163 #endif // NET_SOCKET_SSL_HOST_INFO_H_ |
OLD | NEW |