OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
6 #define CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 6 #define CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
7 | 7 |
8 #include <string> | |
9 #include <vector> | |
10 | |
8 #include "base/time/time.h" | 11 #include "base/time/time.h" |
9 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
13 #include "url/gurl.h" | |
10 | 14 |
11 // This class calculates the severity scores for the different type of SSL | 15 // This class calculates the severity scores for the different type of SSL |
12 // errors. | 16 // errors. |
13 class SSLErrorClassification { | 17 class SSLErrorClassification { |
14 public: | 18 public: |
15 SSLErrorClassification(base::Time current_time, | 19 SSLErrorClassification(base::Time current_time, |
20 const GURL& url, | |
16 const net::X509Certificate& cert); | 21 const net::X509Certificate& cert); |
17 ~SSLErrorClassification(); | 22 ~SSLErrorClassification(); |
18 | 23 |
19 // This method checks whether the user clock is in the past or not. | 24 // This method checks whether the system time is in the past. |
20 static bool IsUserClockInThePast(base::Time time_now); | 25 static bool IsUserClockInThePast(base::Time time_now); |
21 | 26 |
22 // This method checks whether the system time is too far in the future or | 27 // This method checks whether the system time is too far in the future or |
23 // the user is using a version of Chrome which is more than 1 year old. | 28 // the user is using a version of Chrome which is more than 1 year old. |
24 static bool IsUserClockInTheFuture(base::Time time_now); | 29 static bool IsUserClockInTheFuture(base::Time time_now); |
25 | 30 |
31 // This method checks whether the URL has a known Top Level Domain or not. | |
32 static bool IsNotValidURL(const GURL& url); | |
felt
2014/07/16 23:31:47
does this need to be public? does it have a caller
radhikabhar
2014/07/17 01:02:12
Done.
| |
33 | |
26 // A method which calculates the severity score when the ssl error is | 34 // A method which calculates the severity score when the ssl error is |
27 // CERT_DATE_INVALID. | 35 // CERT_DATE_INVALID. |
28 float InvalidDateSeverityScore() const; | 36 float InvalidDateSeverityScore() const; |
29 | 37 |
30 static void RecordUMAStatistics(bool overridable); | 38 // A method which calculates the severity score when the ssl error is |
39 // CERT_COMMON_NAME_INVALID. | |
40 float InvalidCommonNameSeverityScore() const; | |
41 | |
42 void RecordUMAStatisticsDateInvalid(bool overridable); | |
43 void RecordUMAStatisticsNameInvalid(bool overridable); | |
44 void RecordUMAStatisticsAuthorityInvalid(bool overridable); | |
31 base::TimeDelta TimePassedSinceExpiry() const; | 45 base::TimeDelta TimePassedSinceExpiry() const; |
32 | 46 |
33 private: | 47 private: |
34 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestDateInvalidScore); | 48 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestDateInvalidScore); |
49 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestNameMismatch); | |
50 | |
51 // This method checks whether or not the difference between the hostname in | |
52 // the given URL and any DNS name given in the CN or SAN fields of the SSL | |
53 // certificate is "www.". | |
54 bool IsWWWSubDomainMatch() const; | |
55 | |
56 // This method checks whether or not the hostname in the given URL is a | |
57 // subdomain of any DNS name given in the CN or SAN fields of the SSL | |
58 // certificate. | |
59 bool IsSubDomainMatch() const; | |
60 | |
61 // This method checks whether any DNS name given in the CN or SAN fields of | |
62 // the SSL certificate is a subdomain of the given URL or not. | |
63 bool IsSubDomainInverseMatch() const; | |
64 | |
65 // This method checks whether the hostname is too broad for the scope of a | |
66 // wildcard certificate or not. For e.g. it returns true if the host name of | |
67 // the URL is "a.b.example.com" and the DNS name in the CN or SAN field of the | |
68 // SSL certificate is "*.example.com". But, it retuns false for the hostname | |
69 // "b.example.com". | |
70 bool IsSubDomainOutsideWildcard() const; | |
71 bool IsSelfSigned() const; | |
35 | 72 |
36 float CalculateScoreTimePassedSinceExpiry() const; | 73 float CalculateScoreTimePassedSinceExpiry() const; |
37 | 74 |
38 // This stores the current time. | 75 // This stores the current time. |
39 base::Time current_time_; | 76 base::Time current_time_; |
40 | 77 |
78 const GURL& request_url_; | |
79 | |
41 // This stores the certificate. | 80 // This stores the certificate. |
42 const net::X509Certificate& cert_; | 81 const net::X509Certificate& cert_; |
43 }; | 82 }; |
44 | 83 |
45 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 84 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
OLD | NEW |