OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/cert_database.h" | 5 #include "net/base/cert_database.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <certdb.h> | 8 #include <certdb.h> |
9 #include <keyhi.h> | 9 #include <keyhi.h> |
10 #include <pk11pub.h> | 10 #include <pk11pub.h> |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 trust.HasTrustedCA(PR_FALSE, PR_FALSE, PR_TRUE) * TRUSTED_OBJ_SIGN; | 229 trust.HasTrustedCA(PR_FALSE, PR_FALSE, PR_TRUE) * TRUSTED_OBJ_SIGN; |
230 case SERVER_CERT: | 230 case SERVER_CERT: |
231 return trust.HasTrustedPeer(PR_TRUE, PR_FALSE, PR_FALSE) * TRUSTED_SSL + | 231 return trust.HasTrustedPeer(PR_TRUE, PR_FALSE, PR_FALSE) * TRUSTED_SSL + |
232 trust.HasTrustedPeer(PR_FALSE, PR_TRUE, PR_FALSE) * TRUSTED_EMAIL + | 232 trust.HasTrustedPeer(PR_FALSE, PR_TRUE, PR_FALSE) * TRUSTED_EMAIL + |
233 trust.HasTrustedPeer(PR_FALSE, PR_FALSE, PR_TRUE) * TRUSTED_OBJ_SIGN; | 233 trust.HasTrustedPeer(PR_FALSE, PR_FALSE, PR_TRUE) * TRUSTED_OBJ_SIGN; |
234 default: | 234 default: |
235 return UNTRUSTED; | 235 return UNTRUSTED; |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 bool CertDatabase::IsUntrusted(const X509Certificate* cert) const { | |
240 CERTCertTrust nsstrust; | |
241 SECStatus rv = CERT_GetCertTrust(cert->os_cert_handle(), &nsstrust); | |
242 if (rv != SECSuccess) { | |
243 LOG(ERROR) << "CERT_GetCertTrust failed with error " << PORT_GetError(); | |
244 return false; | |
245 } | |
246 | |
247 return nsstrust.sslFlags == 0 && | |
248 nsstrust.emailFlags == 0 && | |
249 nsstrust.objectSigningFlags == 0; | |
wtc
2011/06/29 00:30:45
I believe this is correct only for root certs.
(N
mattm
2011/06/29 01:12:07
Maybe we should only check the sslFlags? If for s
| |
250 } | |
251 | |
239 bool CertDatabase::SetCertTrust(const X509Certificate* cert, | 252 bool CertDatabase::SetCertTrust(const X509Certificate* cert, |
240 CertType type, | 253 CertType type, |
241 unsigned int trusted) { | 254 unsigned int trusted) { |
242 bool success = psm::SetCertTrust(cert, type, trusted); | 255 bool success = psm::SetCertTrust(cert, type, trusted); |
243 if (success) | 256 if (success) |
244 CertDatabase::NotifyObserversOfCertTrustChanged(cert); | 257 CertDatabase::NotifyObserversOfCertTrustChanged(cert); |
245 | 258 |
246 return success; | 259 return success; |
247 } | 260 } |
248 | 261 |
(...skipping 19 matching lines...) Expand all Loading... | |
268 } | 281 } |
269 return true; | 282 return true; |
270 } | 283 } |
271 | 284 |
272 bool CertDatabase::IsReadOnly(const X509Certificate* cert) const { | 285 bool CertDatabase::IsReadOnly(const X509Certificate* cert) const { |
273 PK11SlotInfo* slot = cert->os_cert_handle()->slot; | 286 PK11SlotInfo* slot = cert->os_cert_handle()->slot; |
274 return slot && PK11_IsReadOnly(slot); | 287 return slot && PK11_IsReadOnly(slot); |
275 } | 288 } |
276 | 289 |
277 } // namespace net | 290 } // namespace net |
OLD | NEW |