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