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: */
|
|
|
|
/* 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__NSSCertDBTrustDomain_h
|
|
|
|
#define mozilla_psm__NSSCertDBTrustDomain_h
|
|
|
|
|
2014-03-21 01:29:21 +04:00
|
|
|
#include "pkix/pkixtypes.h"
|
2014-01-21 10:10:33 +04:00
|
|
|
#include "secmodt.h"
|
|
|
|
#include "CertVerifier.h"
|
|
|
|
|
|
|
|
namespace mozilla { namespace psm {
|
|
|
|
|
|
|
|
SECStatus InitializeNSS(const char* dir, bool readOnly);
|
|
|
|
|
2014-01-20 13:30:25 +04:00
|
|
|
void DisableMD5();
|
|
|
|
|
2014-01-21 10:10:33 +04:00
|
|
|
extern const char BUILTIN_ROOTS_MODULE_DEFAULT_NAME[];
|
|
|
|
|
2014-03-13 00:08:48 +04:00
|
|
|
void PORT_Free_string(char* str);
|
|
|
|
|
2014-01-21 10:10:33 +04:00
|
|
|
// The dir parameter is the path to the directory containing the NSS builtin
|
|
|
|
// roots module. Usually this is the same as the path to the other NSS shared
|
|
|
|
// libraries. If it is null then the (library) path will be searched.
|
|
|
|
//
|
|
|
|
// The modNameUTF8 parameter should usually be
|
|
|
|
// BUILTIN_ROOTS_MODULE_DEFAULT_NAME.
|
|
|
|
SECStatus LoadLoadableRoots(/*optional*/ const char* dir,
|
|
|
|
const char* modNameUTF8);
|
|
|
|
|
|
|
|
void UnloadLoadableRoots(const char* modNameUTF8);
|
|
|
|
|
2013-07-09 03:30:59 +04:00
|
|
|
// Caller must free the result with PR_Free
|
|
|
|
char* DefaultServerNicknameForCert(CERTCertificate* cert);
|
|
|
|
|
2014-07-07 02:55:38 +04:00
|
|
|
void SaveIntermediateCerts(const ScopedCERTCertList& certList);
|
2013-07-09 03:30:59 +04:00
|
|
|
|
2014-03-21 01:29:21 +04:00
|
|
|
class NSSCertDBTrustDomain : public mozilla::pkix::TrustDomain
|
2014-02-10 23:41:12 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2014-02-24 10:15:53 +04:00
|
|
|
enum OCSPFetching {
|
|
|
|
NeverFetchOCSP = 0,
|
|
|
|
FetchOCSPForDVSoftFail = 1,
|
|
|
|
FetchOCSPForDVHardFail = 2,
|
|
|
|
FetchOCSPForEV = 3,
|
|
|
|
LocalOnlyOCSPForEV = 4,
|
|
|
|
};
|
|
|
|
NSSCertDBTrustDomain(SECTrustType certDBTrustType, OCSPFetching ocspFetching,
|
2014-02-06 02:49:10 +04:00
|
|
|
OCSPCache& ocspCache, void* pinArg,
|
2014-05-22 02:42:21 +04:00
|
|
|
CertVerifier::ocsp_get_config ocspGETConfig,
|
2014-07-07 02:55:38 +04:00
|
|
|
/*optional*/ CERTChainVerifyCallback* checkChainCallback = nullptr,
|
|
|
|
/*optional*/ ScopedCERTCertList* builtChain = nullptr);
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-03 03:15:16 +04:00
|
|
|
virtual SECStatus FindIssuer(const SECItem& encodedIssuerName,
|
|
|
|
IssuerChecker& checker, PRTime time);
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-03-21 01:29:21 +04:00
|
|
|
virtual SECStatus GetCertTrust(mozilla::pkix::EndEntityOrCA endEntityOrCA,
|
2014-05-16 05:59:52 +04:00
|
|
|
const mozilla::pkix::CertPolicyId& policy,
|
2014-06-03 21:47:25 +04:00
|
|
|
const SECItem& candidateCertDER,
|
2014-04-26 03:29:26 +04:00
|
|
|
/*out*/ mozilla::pkix::TrustLevel* trustLevel);
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-11 06:00:32 +04:00
|
|
|
virtual SECStatus VerifySignedData(
|
|
|
|
const mozilla::pkix::SignedDataWithSignature& signedData,
|
|
|
|
const SECItem& subjectPublicKeyInfo);
|
2014-02-10 23:41:12 +04:00
|
|
|
|
2014-07-07 06:36:05 +04:00
|
|
|
virtual SECStatus DigestBuf(const SECItem& item, /*out*/ uint8_t* digestBuf,
|
|
|
|
size_t digestBufLen);
|
|
|
|
|
2014-03-21 01:29:21 +04:00
|
|
|
virtual SECStatus CheckRevocation(mozilla::pkix::EndEntityOrCA endEntityOrCA,
|
2014-06-20 21:10:51 +04:00
|
|
|
const mozilla::pkix::CertID& certID,
|
2014-02-17 05:35:40 +04:00
|
|
|
PRTime time,
|
2014-06-20 21:10:51 +04:00
|
|
|
/*optional*/ const SECItem* stapledOCSPResponse,
|
|
|
|
/*optional*/ const SECItem* aiaExtension);
|
2014-02-17 05:35:40 +04:00
|
|
|
|
2014-07-07 02:55:38 +04:00
|
|
|
virtual SECStatus IsChainValid(const mozilla::pkix::DERArray& certChain);
|
2014-02-06 02:49:10 +04:00
|
|
|
|
2014-07-16 03:49:00 +04:00
|
|
|
virtual SECStatus CheckPublicKey(const SECItem& subjectPublicKeyInfo);
|
|
|
|
|
2014-02-10 23:41:12 +04:00
|
|
|
private:
|
2014-04-29 03:38:15 +04:00
|
|
|
enum EncodedResponseSource {
|
|
|
|
ResponseIsFromNetwork = 1,
|
|
|
|
ResponseWasStapled = 2
|
|
|
|
};
|
|
|
|
static const PRTime ServerFailureDelay = 5 * 60 * PR_USEC_PER_SEC;
|
2014-03-13 00:08:48 +04:00
|
|
|
SECStatus VerifyAndMaybeCacheEncodedOCSPResponse(
|
2014-06-20 21:10:51 +04:00
|
|
|
const mozilla::pkix::CertID& certID, PRTime time,
|
|
|
|
uint16_t maxLifetimeInDays, const SECItem& encodedResponse,
|
2014-06-20 20:01:57 +04:00
|
|
|
EncodedResponseSource responseSource, /*out*/ bool& expired);
|
2014-03-13 00:08:48 +04:00
|
|
|
|
2014-02-10 23:41:12 +04:00
|
|
|
const SECTrustType mCertDBTrustType;
|
2014-02-24 10:15:53 +04:00
|
|
|
const OCSPFetching mOCSPFetching;
|
2014-03-13 00:08:48 +04:00
|
|
|
OCSPCache& mOCSPCache; // non-owning!
|
2014-02-10 23:41:12 +04:00
|
|
|
void* mPinArg; // non-owning!
|
2014-05-22 02:42:21 +04:00
|
|
|
const CertVerifier::ocsp_get_config mOCSPGetConfig;
|
2014-02-06 02:49:10 +04:00
|
|
|
CERTChainVerifyCallback* mCheckChainCallback; // non-owning!
|
2014-07-07 02:55:38 +04:00
|
|
|
ScopedCERTCertList* mBuiltChain; // non-owning
|
2014-02-10 23:41:12 +04:00
|
|
|
};
|
|
|
|
|
2014-01-21 10:10:33 +04:00
|
|
|
} } // namespace mozilla::psm
|
|
|
|
|
|
|
|
#endif // mozilla_psm__NSSCertDBTrustDomain_h
|