зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1248874 - Replace Scoped.h templates used only by PSM in ScopedNSSTypes.h with UniquePtr equivalents. r=dkeeler
MozReview-Commit-ID: 5OClBV522lv --HG-- extra : transplant_source : G%A3%3B%A0%AC%0D%25%F2%C5K%DC8%0F%90%1B%7Bf%E0%93%F7
This commit is contained in:
Родитель
0efc75d800
Коммит
a150859d8e
|
@ -82,8 +82,7 @@ SECStatus
|
||||||
IsCertBuiltInRoot(CERTCertificate* cert, bool& result)
|
IsCertBuiltInRoot(CERTCertificate* cert, bool& result)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
ScopedPK11SlotList slots;
|
UniquePK11SlotList slots(PK11_GetAllSlotsForCert(cert, nullptr));
|
||||||
slots = PK11_GetAllSlotsForCert(cert, nullptr);
|
|
||||||
if (!slots) {
|
if (!slots) {
|
||||||
if (PORT_GetError() == SEC_ERROR_NO_TOKEN) {
|
if (PORT_GetError() == SEC_ERROR_NO_TOKEN) {
|
||||||
// no list
|
// no list
|
||||||
|
|
|
@ -1017,7 +1017,7 @@ LoadLoadableRoots(/*optional*/ const char* dir, const char* modNameUTF8)
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedSECMODModule rootsModule(SECMOD_LoadUserModule(pkcs11ModuleSpec.get(),
|
UniqueSECMODModule rootsModule(SECMOD_LoadUserModule(pkcs11ModuleSpec.get(),
|
||||||
nullptr, false));
|
nullptr, false));
|
||||||
if (!rootsModule) {
|
if (!rootsModule) {
|
||||||
return SECFailure;
|
return SECFailure;
|
||||||
|
@ -1035,7 +1035,7 @@ void
|
||||||
UnloadLoadableRoots(const char* modNameUTF8)
|
UnloadLoadableRoots(const char* modNameUTF8)
|
||||||
{
|
{
|
||||||
PR_ASSERT(modNameUTF8);
|
PR_ASSERT(modNameUTF8);
|
||||||
ScopedSECMODModule rootsModule(SECMOD_FindModule(modNameUTF8));
|
UniqueSECMODModule rootsModule(SECMOD_FindModule(modNameUTF8));
|
||||||
|
|
||||||
if (rootsModule) {
|
if (rootsModule) {
|
||||||
SECMOD_UnloadUserModule(rootsModule.get());
|
SECMOD_UnloadUserModule(rootsModule.get());
|
||||||
|
|
|
@ -1088,7 +1088,7 @@ GatherEKUTelemetry(const ScopedCERTCertList& certList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the EKU extension
|
// Parse the EKU extension
|
||||||
ScopedCERTOidSequence ekuSequence(
|
UniqueCERTOidSequence ekuSequence(
|
||||||
CERT_DecodeOidSequence(&ekuExtension->value));
|
CERT_DecodeOidSequence(&ekuExtension->value));
|
||||||
if (!ekuSequence) {
|
if (!ekuSequence) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
// This header provides smart pointers and various helpers for code that needs
|
||||||
|
// to interact with NSS.
|
||||||
|
|
||||||
#ifndef mozilla_ScopedNSSTypes_h
|
#ifndef mozilla_ScopedNSSTypes_h
|
||||||
#define mozilla_ScopedNSSTypes_h
|
#define mozilla_ScopedNSSTypes_h
|
||||||
|
|
||||||
|
@ -70,6 +73,7 @@ MapSECStatus(SECStatus rv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alphabetical order by NSS type
|
// Alphabetical order by NSS type
|
||||||
|
// Deprecated: use the equivalent UniquePtr templates instead.
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc,
|
||||||
PRFileDesc,
|
PRFileDesc,
|
||||||
PR_Close)
|
PR_Close)
|
||||||
|
@ -88,25 +92,13 @@ MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTCertList,
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTName,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTName,
|
||||||
CERTName,
|
CERTName,
|
||||||
CERT_DestroyName)
|
CERT_DestroyName)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTOidSequence,
|
|
||||||
CERTOidSequence,
|
|
||||||
CERT_DestroyOidSequence)
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTCertNicknames,
|
|
||||||
CERTCertNicknames,
|
|
||||||
CERT_FreeNicknames)
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTSubjectPublicKeyInfo,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTSubjectPublicKeyInfo,
|
||||||
CERTSubjectPublicKeyInfo,
|
CERTSubjectPublicKeyInfo,
|
||||||
SECKEY_DestroySubjectPublicKeyInfo)
|
SECKEY_DestroySubjectPublicKeyInfo)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTValidity,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedCERTValidity,
|
||||||
CERTValidity,
|
CERTValidity,
|
||||||
CERT_DestroyValidity)
|
CERT_DestroyValidity)
|
||||||
|
// Deprecated: use the equivalent UniquePtr templates instead.
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedNSSCMSMessage,
|
|
||||||
NSSCMSMessage,
|
|
||||||
NSS_CMSMessage_Destroy)
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedNSSCMSSignedData,
|
|
||||||
NSSCMSSignedData,
|
|
||||||
NSS_CMSSignedData_Destroy)
|
|
||||||
|
|
||||||
namespace psm {
|
namespace psm {
|
||||||
|
|
||||||
|
@ -115,30 +107,15 @@ PK11_DestroyContext_true(PK11Context * ctx) {
|
||||||
PK11_DestroyContext(ctx, true);
|
PK11_DestroyContext(ctx, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
|
||||||
SGN_DestroyContext_true(SGNContext* ctx) {
|
|
||||||
SGN_DestroyContext(ctx, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void
|
|
||||||
VFY_DestroyContext_true(VFYContext * ctx) {
|
|
||||||
VFY_DestroyContext(ctx, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mozilla::psm
|
} // namespace mozilla::psm
|
||||||
|
|
||||||
|
// Deprecated: use the equivalent UniquePtr templates instead.
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11Context,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11Context,
|
||||||
PK11Context,
|
PK11Context,
|
||||||
mozilla::psm::PK11_DestroyContext_true)
|
mozilla::psm::PK11_DestroyContext_true)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSGNContext,
|
|
||||||
SGNContext,
|
|
||||||
mozilla::psm::SGN_DestroyContext_true)
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSGNDigestInfo,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSGNDigestInfo,
|
||||||
SGNDigestInfo,
|
SGNDigestInfo,
|
||||||
SGN_DestroyDigestInfo)
|
SGN_DestroyDigestInfo)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedVFYContext,
|
|
||||||
VFYContext,
|
|
||||||
mozilla::psm::VFY_DestroyContext_true)
|
|
||||||
|
|
||||||
/** A more convenient way of dealing with digests calculated into
|
/** A more convenient way of dealing with digests calculated into
|
||||||
* stack-allocated buffers. NSS must be initialized on the main thread before
|
* stack-allocated buffers. NSS must be initialized on the main thread before
|
||||||
|
@ -231,23 +208,16 @@ private:
|
||||||
SECItem item;
|
SECItem item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Deprecated: use the equivalent UniquePtr templates instead.
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11SlotInfo,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11SlotInfo,
|
||||||
PK11SlotInfo,
|
PK11SlotInfo,
|
||||||
PK11_FreeSlot)
|
PK11_FreeSlot)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11SlotList,
|
|
||||||
PK11SlotList,
|
|
||||||
PK11_FreeSlotList)
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11SymKey,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11SymKey,
|
||||||
PK11SymKey,
|
PK11SymKey,
|
||||||
PK11_FreeSymKey)
|
PK11_FreeSymKey)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11GenericObject,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPK11GenericObject,
|
||||||
PK11GenericObject,
|
PK11GenericObject,
|
||||||
PK11_DestroyGenericObject)
|
PK11_DestroyGenericObject)
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSEC_PKCS7ContentInfo,
|
|
||||||
SEC_PKCS7ContentInfo,
|
|
||||||
SEC_PKCS7DestroyContentInfo)
|
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSEC_PKCS12DecoderContext,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSEC_PKCS12DecoderContext,
|
||||||
SEC_PKCS12DecoderContext,
|
SEC_PKCS12DecoderContext,
|
||||||
SEC_PKCS12DecoderFinish)
|
SEC_PKCS12DecoderFinish)
|
||||||
|
@ -263,6 +233,7 @@ PORT_FreeArena_false(PLArenaPool* arena)
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
|
// Deprecated: use the equivalent UniquePtr templates instead.
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPLArenaPool,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPLArenaPool,
|
||||||
PLArenaPool,
|
PLArenaPool,
|
||||||
internal::PORT_FreeArena_false)
|
internal::PORT_FreeArena_false)
|
||||||
|
@ -325,10 +296,10 @@ inline void SECKEYEncryptedPrivateKeyInfo_true(SECKEYEncryptedPrivateKeyInfo * e
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
|
// Deprecated: use the equivalent UniquePtr templates instead.
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECItem,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECItem,
|
||||||
SECItem,
|
SECItem,
|
||||||
internal::SECITEM_FreeItem_true)
|
internal::SECITEM_FreeItem_true)
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECKEYPrivateKey,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECKEYPrivateKey,
|
||||||
SECKEYPrivateKey,
|
SECKEYPrivateKey,
|
||||||
SECKEY_DestroyPrivateKey)
|
SECKEY_DestroyPrivateKey)
|
||||||
|
@ -341,8 +312,6 @@ MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECKEYPublicKey,
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECAlgorithmID,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECAlgorithmID,
|
||||||
SECAlgorithmID,
|
SECAlgorithmID,
|
||||||
internal::SECOID_DestroyAlgorithmID_true)
|
internal::SECOID_DestroyAlgorithmID_true)
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedSECMODModule, SECMODModule,
|
|
||||||
SECMOD_DestroyModule)
|
|
||||||
|
|
||||||
// Emulates MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE, but for UniquePtrs.
|
// Emulates MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE, but for UniquePtrs.
|
||||||
#define MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(name, Type, Deleter) \
|
#define MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(name, Type, Deleter) \
|
||||||
|
@ -355,21 +324,40 @@ typedef UniquePtr<Type, name##DeletePolicy> name;
|
||||||
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTCertificatePolicies,
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTCertificatePolicies,
|
||||||
CERTCertificatePolicies,
|
CERTCertificatePolicies,
|
||||||
CERT_DestroyCertificatePoliciesExtension)
|
CERT_DestroyCertificatePoliciesExtension)
|
||||||
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTCertNicknames,
|
||||||
|
CERTCertNicknames,
|
||||||
|
CERT_FreeNicknames)
|
||||||
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTOidSequence,
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTOidSequence,
|
||||||
CERTOidSequence,
|
CERTOidSequence,
|
||||||
CERT_DestroyOidSequence)
|
CERT_DestroyOidSequence)
|
||||||
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTUserNotice,
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueCERTUserNotice,
|
||||||
CERTUserNotice,
|
CERTUserNotice,
|
||||||
CERT_DestroyUserNotice)
|
CERT_DestroyUserNotice)
|
||||||
|
|
||||||
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueNSSCMSMessage,
|
||||||
|
NSSCMSMessage,
|
||||||
|
NSS_CMSMessage_Destroy)
|
||||||
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueNSSCMSSignedData,
|
||||||
|
NSSCMSSignedData,
|
||||||
|
NSS_CMSSignedData_Destroy)
|
||||||
|
|
||||||
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniquePK11SlotList,
|
||||||
|
PK11SlotList,
|
||||||
|
PK11_FreeSlotList)
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniquePLArenaPool,
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniquePLArenaPool,
|
||||||
PLArenaPool,
|
PLArenaPool,
|
||||||
internal::PORT_FreeArena_false)
|
internal::PORT_FreeArena_false)
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueSECItem,
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueSECItem,
|
||||||
SECItem,
|
SECItem,
|
||||||
internal::SECITEM_FreeItem_true)
|
internal::SECITEM_FreeItem_true)
|
||||||
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueSECKEYPublicKey,
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueSECKEYPublicKey,
|
||||||
SECKEYPublicKey,
|
SECKEYPublicKey,
|
||||||
SECKEY_DestroyPublicKey)
|
SECKEY_DestroyPublicKey)
|
||||||
|
MOZ_TYPE_SPECIFIC_UNIQUE_PTR_TEMPLATE(UniqueSECMODModule,
|
||||||
|
SECMODModule,
|
||||||
|
SECMOD_DestroyModule)
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif // mozilla_ScopedNSSTypes_h
|
#endif // mozilla_ScopedNSSTypes_h
|
||||||
|
|
|
@ -103,7 +103,8 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(nsIInterfaceRequestor *ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedCERTCertNicknames nicknames(getNSSCertNicknamesFromCertList(certList.get()));
|
UniqueCERTCertNicknames nicknames(
|
||||||
|
getNSSCertNicknamesFromCertList(certList.get()));
|
||||||
if (!nicknames) {
|
if (!nicknames) {
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ nsPkcs11::DeleteModule(const nsAString& aModuleName)
|
||||||
// before we call SECMOD_DeleteModule, below.
|
// before we call SECMOD_DeleteModule, below.
|
||||||
#ifndef MOZ_NO_SMART_CARDS
|
#ifndef MOZ_NO_SMART_CARDS
|
||||||
{
|
{
|
||||||
mozilla::ScopedSECMODModule module(SECMOD_FindModule(moduleName.get()));
|
mozilla::UniqueSECMODModule module(SECMOD_FindModule(moduleName.get()));
|
||||||
if (!module) {
|
if (!module) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ nsPkcs11::AddModule(const nsAString& aModuleName,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MOZ_NO_SMART_CARDS
|
#ifndef MOZ_NO_SMART_CARDS
|
||||||
mozilla::ScopedSECMODModule module(SECMOD_FindModule(moduleName.get()));
|
mozilla::UniqueSECMODModule module(SECMOD_FindModule(moduleName.get()));
|
||||||
if (!module) {
|
if (!module) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ VerifyCMSDetachedSignatureIncludingCertificate(
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedNSSCMSMessage
|
UniqueNSSCMSMessage
|
||||||
cmsMsg(NSS_CMSMessage_CreateFromDER(const_cast<SECItem*>(&buffer), nullptr,
|
cmsMsg(NSS_CMSMessage_CreateFromDER(const_cast<SECItem*>(&buffer), nullptr,
|
||||||
nullptr, nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr, nullptr,
|
||||||
nullptr));
|
nullptr));
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "CertVerifier.h"
|
#include "CertVerifier.h"
|
||||||
#include "ExtendedValidation.h"
|
#include "ExtendedValidation.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
|
#include "mozilla/unused.h"
|
||||||
#include "pkix/pkixnss.h"
|
#include "pkix/pkixnss.h"
|
||||||
#include "pkix/pkixtypes.h"
|
#include "pkix/pkixtypes.h"
|
||||||
#include "nsNSSComponent.h" // for PIPNSS string bundle calls.
|
#include "nsNSSComponent.h" // for PIPNSS string bundle calls.
|
||||||
|
@ -923,14 +924,13 @@ nsNSSCertificate::GetAllTokenNames(uint32_t* aLength, char16_t*** aTokenNames)
|
||||||
*aTokenNames = nullptr;
|
*aTokenNames = nullptr;
|
||||||
|
|
||||||
// Get the slots from NSS
|
// Get the slots from NSS
|
||||||
ScopedPK11SlotList slots;
|
|
||||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Getting slots for \"%s\"\n", mCert->nickname));
|
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("Getting slots for \"%s\"\n", mCert->nickname));
|
||||||
slots = PK11_GetAllSlotsForCert(mCert.get(), nullptr);
|
UniquePK11SlotList slots(PK11_GetAllSlotsForCert(mCert.get(), nullptr));
|
||||||
if (!slots) {
|
if (!slots) {
|
||||||
if (PORT_GetError() == SEC_ERROR_NO_TOKEN)
|
if (PORT_GetError() == SEC_ERROR_NO_TOKEN) {
|
||||||
return NS_OK; // List of slots is empty, return empty array
|
return NS_OK; // List of slots is empty, return empty array
|
||||||
else
|
}
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the token names from slots
|
// read the token names from slots
|
||||||
|
@ -1149,7 +1149,7 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode,
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedNSSCMSMessage cmsg(NSS_CMSMessage_Create(nullptr));
|
UniqueNSSCMSMessage cmsg(NSS_CMSMessage_Create(nullptr));
|
||||||
if (!cmsg) {
|
if (!cmsg) {
|
||||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
||||||
("nsNSSCertificate::ExportAsCMS - can't create CMS message\n"));
|
("nsNSSCertificate::ExportAsCMS - can't create CMS message\n"));
|
||||||
|
@ -1157,8 +1157,8 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
// first, create SignedData with the certificate only (no chain)
|
// first, create SignedData with the certificate only (no chain)
|
||||||
ScopedNSSCMSSignedData sigd(
|
UniqueNSSCMSSignedData sigd(
|
||||||
NSS_CMSSignedData_CreateCertsOnly(cmsg, mCert.get(), false));
|
NSS_CMSSignedData_CreateCertsOnly(cmsg.get(), mCert.get(), false));
|
||||||
if (!sigd) {
|
if (!sigd) {
|
||||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
||||||
("nsNSSCertificate::ExportAsCMS - can't create SignedData\n"));
|
("nsNSSCertificate::ExportAsCMS - can't create SignedData\n"));
|
||||||
|
@ -1182,7 +1182,7 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode,
|
||||||
ScopedCERTCertificateList certChain(
|
ScopedCERTCertificateList certChain(
|
||||||
CERT_CertChainFromCert(issuerCert, certUsageAnyCA, includeRoot));
|
CERT_CertChainFromCert(issuerCert, certUsageAnyCA, includeRoot));
|
||||||
if (certChain) {
|
if (certChain) {
|
||||||
if (NSS_CMSSignedData_AddCertList(sigd, certChain) == SECSuccess) {
|
if (NSS_CMSSignedData_AddCertList(sigd.get(), certChain) == SECSuccess) {
|
||||||
certChain.forget();
|
certChain.forget();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1193,7 +1193,7 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// try to add the issuerCert, at least
|
// try to add the issuerCert, at least
|
||||||
if (NSS_CMSSignedData_AddCertificate(sigd, issuerCert)
|
if (NSS_CMSSignedData_AddCertificate(sigd.get(), issuerCert)
|
||||||
== SECSuccess) {
|
== SECSuccess) {
|
||||||
issuerCert.forget();
|
issuerCert.forget();
|
||||||
}
|
}
|
||||||
|
@ -1206,10 +1206,10 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSSCMSContentInfo* cinfo = NSS_CMSMessage_GetContentInfo(cmsg);
|
NSSCMSContentInfo* cinfo = NSS_CMSMessage_GetContentInfo(cmsg.get());
|
||||||
if (NSS_CMSContentInfo_SetContent_SignedData(cmsg, cinfo, sigd)
|
if (NSS_CMSContentInfo_SetContent_SignedData(cmsg.get(), cinfo, sigd.get())
|
||||||
== SECSuccess) {
|
== SECSuccess) {
|
||||||
sigd.forget();
|
Unused << sigd.release();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
|
||||||
|
@ -1225,7 +1225,7 @@ nsNSSCertificate::ExportAsCMS(uint32_t chainMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
SECItem certP7 = { siBuffer, nullptr, 0 };
|
SECItem certP7 = { siBuffer, nullptr, 0 };
|
||||||
NSSCMSEncoderContext* ecx = NSS_CMSEncoder_Start(cmsg, nullptr, nullptr,
|
NSSCMSEncoderContext* ecx = NSS_CMSEncoder_Start(cmsg.get(), nullptr, nullptr,
|
||||||
&certP7, arena, nullptr,
|
&certP7, arena, nullptr,
|
||||||
nullptr, nullptr, nullptr,
|
nullptr, nullptr, nullptr,
|
||||||
nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
|
|
|
@ -2092,7 +2092,7 @@ ClientAuthDataRunnable::RunOnTargetThread()
|
||||||
ScopedSECKEYPrivateKey privKey;
|
ScopedSECKEYPrivateKey privKey;
|
||||||
ScopedCERTCertList certList;
|
ScopedCERTCertList certList;
|
||||||
CERTCertListNode* node;
|
CERTCertListNode* node;
|
||||||
ScopedCERTCertNicknames nicknames;
|
UniqueCERTCertNicknames nicknames;
|
||||||
int keyError = 0; // used for private key retrieval error
|
int keyError = 0; // used for private key retrieval error
|
||||||
SSM_UserCertChoice certChoice;
|
SSM_UserCertChoice certChoice;
|
||||||
int32_t NumberOfCerts = 0;
|
int32_t NumberOfCerts = 0;
|
||||||
|
@ -2296,7 +2296,7 @@ ClientAuthDataRunnable::RunOnTargetThread()
|
||||||
goto noCert;
|
goto noCert;
|
||||||
}
|
}
|
||||||
|
|
||||||
nicknames = getNSSCertNicknamesFromCertList(certList.get());
|
nicknames.reset(getNSSCertNicknamesFromCertList(certList.get()));
|
||||||
|
|
||||||
if (!nicknames) {
|
if (!nicknames) {
|
||||||
goto loser;
|
goto loser;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче