2014-01-20 22:10:33 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-10-27 00:11:35 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_psm__CertVerifier_h
|
|
|
|
#define mozilla_psm__CertVerifier_h
|
|
|
|
|
2014-03-20 14:29:21 -07:00
|
|
|
#include "pkix/pkixtypes.h"
|
2014-03-12 13:08:48 -07:00
|
|
|
#include "OCSPCache.h"
|
2012-10-27 00:11:35 -07:00
|
|
|
|
|
|
|
namespace mozilla { namespace psm {
|
|
|
|
|
2014-02-05 14:49:10 -08:00
|
|
|
struct ChainValidationCallbackState;
|
|
|
|
|
2012-10-27 00:11:35 -07:00
|
|
|
class CertVerifier
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef unsigned int Flags;
|
2014-01-17 11:04:09 -08:00
|
|
|
// XXX: FLAG_LOCAL_ONLY is ignored in the classic verification case
|
2012-10-27 00:11:35 -07:00
|
|
|
static const Flags FLAG_LOCAL_ONLY;
|
2014-01-17 11:04:09 -08:00
|
|
|
// Don't perform fallback DV validation on EV validation failure.
|
2014-01-24 13:57:35 -08:00
|
|
|
static const Flags FLAG_MUST_BE_EV;
|
2012-10-27 00:11:35 -07:00
|
|
|
|
|
|
|
// *evOidPolicy == SEC_OID_UNKNOWN means the cert is NOT EV
|
2013-12-06 13:42:44 -08:00
|
|
|
// Only one usage per verification is supported.
|
2014-01-21 17:30:44 -08:00
|
|
|
SECStatus VerifyCert(CERTCertificate* cert,
|
2012-10-27 00:11:35 -07:00
|
|
|
const SECCertificateUsage usage,
|
|
|
|
const PRTime time,
|
2014-01-19 14:05:40 -08:00
|
|
|
void* pinArg,
|
2014-02-05 14:49:10 -08:00
|
|
|
const char* hostname,
|
2012-10-27 00:11:35 -07:00
|
|
|
const Flags flags = 0,
|
2014-02-05 14:49:10 -08:00
|
|
|
/*optional in*/ const SECItem* stapledOCSPResponse = nullptr,
|
2014-03-20 14:29:21 -07:00
|
|
|
/*optional out*/ mozilla::pkix::ScopedCERTCertList* validationChain = nullptr,
|
2014-01-22 17:13:19 -08:00
|
|
|
/*optional out*/ SECOidTag* evOidPolicy = nullptr ,
|
|
|
|
/*optional out*/ CERTVerifyLog* verifyLog = nullptr);
|
2012-10-27 00:11:35 -07:00
|
|
|
|
2013-07-08 16:30:59 -07:00
|
|
|
SECStatus VerifySSLServerCert(
|
|
|
|
CERTCertificate* peerCert,
|
2013-09-27 19:53:36 -07:00
|
|
|
/*optional*/ const SECItem* stapledOCSPResponse,
|
2013-07-08 16:30:59 -07:00
|
|
|
PRTime time,
|
|
|
|
/*optional*/ void* pinarg,
|
|
|
|
const char* hostname,
|
|
|
|
bool saveIntermediatesInPermanentDatabase = false,
|
2014-03-20 14:29:21 -07:00
|
|
|
/*optional out*/ mozilla::pkix::ScopedCERTCertList* certChainOut = nullptr,
|
2013-07-08 16:30:59 -07:00
|
|
|
/*optional out*/ SECOidTag* evOidPolicy = nullptr);
|
|
|
|
|
|
|
|
|
2014-01-19 14:05:40 -08:00
|
|
|
enum implementation_config {
|
|
|
|
classic = 0,
|
|
|
|
#ifndef NSS_NO_LIBPKIX
|
|
|
|
libpkix = 1,
|
|
|
|
#endif
|
2014-03-20 14:29:21 -07:00
|
|
|
mozillapkix = 2
|
2014-01-19 14:05:40 -08:00
|
|
|
};
|
|
|
|
|
2014-02-05 14:49:10 -08:00
|
|
|
enum pinning_enforcement_config {
|
|
|
|
pinningDisabled = 0,
|
|
|
|
pinningAllowUserCAMITM = 1,
|
2014-05-19 13:04:40 -07:00
|
|
|
pinningStrict = 2,
|
|
|
|
pinningEnforceTestMode = 3
|
2014-02-05 14:49:10 -08:00
|
|
|
};
|
|
|
|
|
2012-10-27 00:11:35 -07:00
|
|
|
enum missing_cert_download_config { missing_cert_download_off = 0, missing_cert_download_on };
|
|
|
|
enum crl_download_config { crl_local_only = 0, crl_download_allowed };
|
|
|
|
enum ocsp_download_config { ocsp_off = 0, ocsp_on };
|
|
|
|
enum ocsp_strict_config { ocsp_relaxed = 0, ocsp_strict };
|
2013-10-24 14:32:09 -07:00
|
|
|
enum ocsp_get_config { ocsp_get_disabled = 0, ocsp_get_enabled = 1 };
|
2012-10-27 00:11:35 -07:00
|
|
|
|
|
|
|
bool IsOCSPDownloadEnabled() const { return mOCSPDownloadEnabled; }
|
|
|
|
|
2014-02-10 11:41:12 -08:00
|
|
|
CertVerifier(implementation_config ic,
|
|
|
|
#ifndef NSS_NO_LIBPKIX
|
|
|
|
missing_cert_download_config ac, crl_download_config cdc,
|
|
|
|
#endif
|
|
|
|
ocsp_download_config odc, ocsp_strict_config osc,
|
2014-02-05 14:49:10 -08:00
|
|
|
ocsp_get_config ogc,
|
|
|
|
pinning_enforcement_config pinningEnforcementLevel);
|
2012-10-27 00:11:35 -07:00
|
|
|
~CertVerifier();
|
|
|
|
|
2014-03-12 13:08:48 -07:00
|
|
|
void ClearOCSPCache() { mOCSPCache.Clear(); }
|
|
|
|
|
2014-01-19 14:05:40 -08:00
|
|
|
const implementation_config mImplementation;
|
2014-02-10 11:41:12 -08:00
|
|
|
#ifndef NSS_NO_LIBPKIX
|
2012-10-27 00:11:35 -07:00
|
|
|
const bool mMissingCertDownloadEnabled;
|
|
|
|
const bool mCRLDownloadEnabled;
|
2014-02-10 11:41:12 -08:00
|
|
|
#endif
|
2012-10-27 00:11:35 -07:00
|
|
|
const bool mOCSPDownloadEnabled;
|
|
|
|
const bool mOCSPStrict;
|
2013-10-24 14:32:09 -07:00
|
|
|
const bool mOCSPGETEnabled;
|
2014-02-05 14:49:10 -08:00
|
|
|
const pinning_enforcement_config mPinningEnforcementLevel;
|
2014-02-10 11:41:12 -08:00
|
|
|
|
|
|
|
private:
|
2014-03-20 14:29:21 -07:00
|
|
|
SECStatus MozillaPKIXVerifyCert(CERTCertificate* cert,
|
2014-02-10 11:41:12 -08:00
|
|
|
const SECCertificateUsage usage,
|
|
|
|
const PRTime time,
|
|
|
|
void* pinArg,
|
|
|
|
const Flags flags,
|
2014-02-05 14:49:10 -08:00
|
|
|
ChainValidationCallbackState* callbackState,
|
2014-02-16 17:35:40 -08:00
|
|
|
/*optional*/ const SECItem* stapledOCSPResponse,
|
2014-03-20 14:29:21 -07:00
|
|
|
/*optional out*/ mozilla::pkix::ScopedCERTCertList* validationChain,
|
2014-02-23 22:15:53 -08:00
|
|
|
/*optional out*/ SECOidTag* evOidPolicy);
|
2014-03-12 13:08:48 -07:00
|
|
|
|
|
|
|
OCSPCache mOCSPCache;
|
2012-10-27 00:11:35 -07:00
|
|
|
};
|
|
|
|
|
2013-07-10 23:47:09 -07:00
|
|
|
void InitCertVerifierLog();
|
2012-10-27 00:11:35 -07:00
|
|
|
} } // namespace mozilla::psm
|
|
|
|
|
|
|
|
#endif // mozilla_psm__CertVerifier_h
|