Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: net/base/ssl_client_socket_win.cc

Issue 17471: Measure how often the users are encountering MD5... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/ssl_client_socket_win.h ('k') | net/build/net.vcproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/base/ssl_client_socket_win.h" 5 #include "net/base/ssl_client_socket_win.h"
6 6
7 #include <schnlsp.h> 7 #include <schnlsp.h>
8 8
9 #include "base/lock.h" 9 #include "base/lock.h"
10 #include "base/singleton.h" 10 #include "base/singleton.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "net/base/connection_type_histograms.h"
12 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
13 #include "net/base/scoped_cert_chain_context.h" 14 #include "net/base/scoped_cert_chain_context.h"
14 #include "net/base/ssl_info.h" 15 #include "net/base/ssl_info.h"
15 16
16 #pragma comment(lib, "secur32.lib") 17 #pragma comment(lib, "secur32.lib")
17 18
18 namespace net { 19 namespace net {
19 20
20 //----------------------------------------------------------------------------- 21 //-----------------------------------------------------------------------------
21 22
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 &ctxt_, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &server_cert_); 1015 &ctxt_, SECPKG_ATTR_REMOTE_CERT_CONTEXT, &server_cert_);
1015 if (status != SEC_E_OK) { 1016 if (status != SEC_E_OK) {
1016 DLOG(ERROR) << "QueryContextAttributes failed: " << status; 1017 DLOG(ERROR) << "QueryContextAttributes failed: " << status;
1017 return MapSecurityError(status); 1018 return MapSecurityError(status);
1018 } 1019 }
1019 1020
1020 completed_handshake_ = true; 1021 completed_handshake_ = true;
1021 return VerifyServerCert(); 1022 return VerifyServerCert();
1022 } 1023 }
1023 1024
1025 // static
1026 void SSLClientSocketWin::LogConnectionTypeMetrics(
1027 PCCERT_CHAIN_CONTEXT chain_context) {
1028 UpdateConnectionTypeHistograms(CONNECTION_SSL);
1029
1030 PCERT_SIMPLE_CHAIN first_chain = chain_context->rgpChain[0];
1031 int num_elements = first_chain->cElement;
1032 PCERT_CHAIN_ELEMENT* element = first_chain->rgpElement;
1033 bool has_md5 = false;
1034 bool has_md2 = false;
1035 bool has_md4 = false;
1036
1037 // Each chain starts with the end entity certificate and ends with the root
1038 // CA certificate. Do not inspect the signature algorithm of the root CA
1039 // certificate because the signature on the trust anchor is not important.
1040 for (int i = 0; i < num_elements - 1; ++i) {
1041 PCCERT_CONTEXT cert = element[i]->pCertContext;
1042 const char* algorithm = cert->pCertInfo->SignatureAlgorithm.pszObjId;
1043 if (strcmp(algorithm, szOID_RSA_MD5RSA) == 0) {
1044 // md5WithRSAEncryption: 1.2.840.113549.1.1.4
1045 has_md5 = true;
1046 } else if (strcmp(algorithm, szOID_RSA_MD2RSA) == 0) {
1047 // md2WithRSAEncryption: 1.2.840.113549.1.1.2
1048 has_md2 = true;
1049 } else if (strcmp(algorithm, szOID_RSA_MD4RSA) == 0) {
1050 // md4WithRSAEncryption: 1.2.840.113549.1.1.3
1051 has_md4 = true;
1052 }
1053 }
1054
1055 if (has_md5)
1056 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD5);
1057 if (has_md2)
1058 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD2);
1059 if (has_md4)
1060 UpdateConnectionTypeHistograms(CONNECTION_SSL_MD4);
1061 }
1062
1024 // Set server_cert_status_ and return OK or a network error. 1063 // Set server_cert_status_ and return OK or a network error.
1025 int SSLClientSocketWin::VerifyServerCert() { 1064 int SSLClientSocketWin::VerifyServerCert() {
1026 DCHECK(server_cert_); 1065 DCHECK(server_cert_);
1027 server_cert_status_ = 0; 1066 server_cert_status_ = 0;
1028 1067
1029 // Build and validate certificate chain. 1068 // Build and validate certificate chain.
1030 1069
1031 CERT_CHAIN_PARA chain_para; 1070 CERT_CHAIN_PARA chain_para;
1032 memset(&chain_para, 0, sizeof(chain_para)); 1071 memset(&chain_para, 0, sizeof(chain_para));
1033 chain_para.cbSize = sizeof(chain_para); 1072 chain_para.cbSize = sizeof(chain_para);
(...skipping 17 matching lines...) Expand all
1051 NULL, // current system time 1090 NULL, // current system time
1052 server_cert_->hCertStore, // search this store 1091 server_cert_->hCertStore, // search this store
1053 &chain_para, 1092 &chain_para,
1054 flags, 1093 flags,
1055 NULL, // reserved 1094 NULL, // reserved
1056 &chain_context)) { 1095 &chain_context)) {
1057 return MapSecurityError(GetLastError()); 1096 return MapSecurityError(GetLastError());
1058 } 1097 }
1059 ScopedCertChainContext scoped_chain_context(chain_context); 1098 ScopedCertChainContext scoped_chain_context(chain_context);
1060 1099
1100 LogConnectionTypeMetrics(chain_context);
1101
1061 server_cert_status_ |= MapCertChainErrorStatusToCertStatus( 1102 server_cert_status_ |= MapCertChainErrorStatusToCertStatus(
1062 chain_context->TrustStatus.dwErrorStatus); 1103 chain_context->TrustStatus.dwErrorStatus);
1063 1104
1064 std::wstring wstr_hostname = ASCIIToWide(hostname_); 1105 std::wstring wstr_hostname = ASCIIToWide(hostname_);
1065 1106
1066 SSL_EXTRA_CERT_CHAIN_POLICY_PARA extra_policy_para; 1107 SSL_EXTRA_CERT_CHAIN_POLICY_PARA extra_policy_para;
1067 memset(&extra_policy_para, 0, sizeof(extra_policy_para)); 1108 memset(&extra_policy_para, 0, sizeof(extra_policy_para));
1068 extra_policy_para.cbSize = sizeof(extra_policy_para); 1109 extra_policy_para.cbSize = sizeof(extra_policy_para);
1069 extra_policy_para.dwAuthType = AUTHTYPE_SERVER; 1110 extra_policy_para.dwAuthType = AUTHTYPE_SERVER;
1070 extra_policy_para.fdwChecks = 0; 1111 extra_policy_para.fdwChecks = 0;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 // compatible with WinHTTP, which doesn't report this error (bug 3004). 1184 // compatible with WinHTTP, which doesn't report this error (bug 3004).
1144 server_cert_status_ &= ~CERT_STATUS_NO_REVOCATION_MECHANISM; 1185 server_cert_status_ &= ~CERT_STATUS_NO_REVOCATION_MECHANISM;
1145 1186
1146 if (IsCertStatusError(server_cert_status_)) 1187 if (IsCertStatusError(server_cert_status_))
1147 return MapCertStatusToNetError(server_cert_status_); 1188 return MapCertStatusToNetError(server_cert_status_);
1148 return OK; 1189 return OK;
1149 } 1190 }
1150 1191
1151 } // namespace net 1192 } // namespace net
1152 1193
OLDNEW
« no previous file with comments | « net/base/ssl_client_socket_win.h ('k') | net/build/net.vcproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698