2014-01-21 10:10:33 +04: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 11:11:35 +04: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-01-23 05:13:19 +04:00
|
|
|
#include "insanity/pkixtypes.h"
|
2012-10-27 11:11:35 +04:00
|
|
|
|
|
|
|
namespace mozilla { namespace psm {
|
|
|
|
|
|
|
|
class CertVerifier
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef unsigned int Flags;
|
2014-01-17 23:04:09 +04:00
|
|
|
// XXX: FLAG_LOCAL_ONLY is ignored in the classic verification case
|
2012-10-27 11:11:35 +04:00
|
|
|
static const Flags FLAG_LOCAL_ONLY;
|
2014-01-17 23:04:09 +04:00
|
|
|
// Don't perform fallback DV validation on EV validation failure.
|
2014-01-25 01:57:35 +04:00
|
|
|
static const Flags FLAG_MUST_BE_EV;
|
2012-10-27 11:11:35 +04:00
|
|
|
|
|
|
|
// *evOidPolicy == SEC_OID_UNKNOWN means the cert is NOT EV
|
2013-12-07 01:42:44 +04:00
|
|
|
// Only one usage per verification is supported.
|
2014-01-22 05:30:44 +04:00
|
|
|
SECStatus VerifyCert(CERTCertificate* cert,
|
2013-09-28 06:53:36 +04:00
|
|
|
/*optional*/ const SECItem* stapledOCSPResponse,
|
2012-10-27 11:11:35 +04:00
|
|
|
const SECCertificateUsage usage,
|
|
|
|
const PRTime time,
|
2014-01-20 02:05:40 +04:00
|
|
|
void* pinArg,
|
2012-10-27 11:11:35 +04:00
|
|
|
const Flags flags = 0,
|
2014-01-23 05:13:19 +04:00
|
|
|
/*optional out*/ insanity::pkix::ScopedCERTCertList* validationChain = nullptr,
|
|
|
|
/*optional out*/ SECOidTag* evOidPolicy = nullptr ,
|
|
|
|
/*optional out*/ CERTVerifyLog* verifyLog = nullptr);
|
2012-10-27 11:11:35 +04:00
|
|
|
|
2013-07-09 03:30:59 +04:00
|
|
|
SECStatus VerifySSLServerCert(
|
|
|
|
CERTCertificate* peerCert,
|
2013-09-28 06:53:36 +04:00
|
|
|
/*optional*/ const SECItem* stapledOCSPResponse,
|
2013-07-09 03:30:59 +04:00
|
|
|
PRTime time,
|
|
|
|
/*optional*/ void* pinarg,
|
|
|
|
const char* hostname,
|
|
|
|
bool saveIntermediatesInPermanentDatabase = false,
|
|
|
|
/*optional out*/ insanity::pkix::ScopedCERTCertList* certChainOut = nullptr,
|
|
|
|
/*optional out*/ SECOidTag* evOidPolicy = nullptr);
|
|
|
|
|
|
|
|
|
2014-01-20 02:05:40 +04:00
|
|
|
enum implementation_config {
|
|
|
|
classic = 0,
|
|
|
|
#ifndef NSS_NO_LIBPKIX
|
|
|
|
libpkix = 1,
|
|
|
|
#endif
|
2014-02-10 23:41:12 +04:00
|
|
|
insanity = 2
|
2014-01-20 02:05:40 +04:00
|
|
|
};
|
|
|
|
|
2012-10-27 11:11:35 +04: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-25 01:32:09 +04:00
|
|
|
enum ocsp_get_config { ocsp_get_disabled = 0, ocsp_get_enabled = 1 };
|
2012-10-27 11:11:35 +04:00
|
|
|
|
|
|
|
bool IsOCSPDownloadEnabled() const { return mOCSPDownloadEnabled; }
|
|
|
|
|
2014-02-10 23:41:12 +04: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,
|
|
|
|
ocsp_get_config ogc);
|
2012-10-27 11:11:35 +04:00
|
|
|
~CertVerifier();
|
|
|
|
|
2014-01-20 02:05:40 +04:00
|
|
|
const implementation_config mImplementation;
|
2014-02-10 23:41:12 +04:00
|
|
|
#ifndef NSS_NO_LIBPKIX
|
2012-10-27 11:11:35 +04:00
|
|
|
const bool mMissingCertDownloadEnabled;
|
|
|
|
const bool mCRLDownloadEnabled;
|
2014-02-10 23:41:12 +04:00
|
|
|
#endif
|
2012-10-27 11:11:35 +04:00
|
|
|
const bool mOCSPDownloadEnabled;
|
|
|
|
const bool mOCSPStrict;
|
2013-10-25 01:32:09 +04:00
|
|
|
const bool mOCSPGETEnabled;
|
2014-02-10 23:41:12 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
SECStatus InsanityVerifyCert(CERTCertificate* cert,
|
|
|
|
const SECCertificateUsage usage,
|
|
|
|
const PRTime time,
|
|
|
|
void* pinArg,
|
|
|
|
const Flags flags,
|
2014-02-17 05:35:40 +04:00
|
|
|
/*optional*/ const SECItem* stapledOCSPResponse,
|
2014-02-10 23:41:12 +04:00
|
|
|
/*optional out*/ insanity::pkix::ScopedCERTCertList* validationChain);
|
2012-10-27 11:11:35 +04:00
|
|
|
};
|
|
|
|
|
2013-07-11 10:47:09 +04:00
|
|
|
void InitCertVerifierLog();
|
2012-10-27 11:11:35 +04:00
|
|
|
} } // namespace mozilla::psm
|
|
|
|
|
|
|
|
#endif // mozilla_psm__CertVerifier_h
|