micro509 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/internal/asn1/oids.js +1 -1
- package/dist/internal/asn1/oids.js.map +1 -1
- package/dist/revocation/chain.d.ts +29 -2
- package/dist/revocation/chain.js +1 -1
- package/dist/revocation/chain.js.map +1 -1
- package/dist/revocation/crl.d.ts +3 -1
- package/dist/revocation/crl.js +1 -1
- package/dist/revocation/crl.js.map +1 -1
- package/dist/revocation/ocsp.d.ts +44 -6
- package/dist/revocation/ocsp.js +1 -1
- package/dist/revocation/ocsp.js.map +1 -1
- package/dist/revocation/revocation.d.ts +4 -4
- package/dist/revocation/revocation.js.map +1 -1
- package/dist/revocation.d.ts +3 -3
- package/dist/revocation.js +1 -1
- package/dist/verify/identity.d.ts +2 -2
- package/dist/verify/identity.js.map +1 -1
- package/dist/verify/verify.d.ts +10 -5
- package/dist/verify/verify.js +1 -1
- package/dist/verify/verify.js.map +1 -1
- package/dist/verify.d.ts +2 -2
- package/dist/verify.js +1 -1
- package/package.json +12 -47
package/README.md
CHANGED
|
@@ -40,10 +40,10 @@ PKCS#7 SignedData, PFX/PKCS#12, PEM handling, and key
|
|
|
40
40
|
import/export.
|
|
41
41
|
|
|
42
42
|
And when verification fails, you get typed results your code
|
|
43
|
-
can act on: [
|
|
44
|
-
and structured failure details instead of `false`.
|
|
43
|
+
can act on: [a typed error code for every failure mode], the failing
|
|
44
|
+
certificate index, and structured failure details instead of `false`.
|
|
45
45
|
|
|
46
|
-
[
|
|
46
|
+
[a typed error code for every failure mode]: https://micro509.kjanat.dev/guide/verification#error-codes
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
if (!result.ok) {
|
|
@@ -117,15 +117,18 @@ console.log(csr.pem);
|
|
|
117
117
|
Parse a certificate:
|
|
118
118
|
|
|
119
119
|
```ts
|
|
120
|
-
import { parseCertificatePem } from 'micro509';
|
|
120
|
+
import { parseCertificatePem, unwrap } from 'micro509';
|
|
121
121
|
|
|
122
122
|
// Using certificate from previous example
|
|
123
|
-
const parsed = parseCertificatePem(certificate.pem);
|
|
123
|
+
const parsed = unwrap(parseCertificatePem(certificate.pem));
|
|
124
124
|
console.log(parsed.subject.values.commonName);
|
|
125
125
|
console.log(parsed.extendedKeyUsage);
|
|
126
126
|
console.log(parsed.authorityInfoAccess);
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
`parseCertificatePem` returns a typed `Result` — check `result.ok`, or
|
|
130
|
+
`unwrap()` to throw on malformed input.
|
|
131
|
+
|
|
129
132
|
Verify a chain:
|
|
130
133
|
|
|
131
134
|
```ts
|
package/dist/index.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ import { DecodedExtensionMap, DecodedExtensionValue, ExtensionDecoder, Extension
|
|
|
9
9
|
import { CreatePfxErrorCode, CreatePfxFailure, CreatePfxInput, CreatePfxResult, ParsePfxErrorCode, ParsePfxFailure, ParsePfxOptions, ParsePfxResult, ParsedPfx, ParsedPfxAttribute, ParsedPfxBag, ParsedPfxBagAttributes, PfxBagAttributesInput, PfxCertificateBagInput, PfxCertificateSource, PfxEncryptionOptions, PfxMaterial, PfxPrivateKeyBagInput, PfxPrivateKeySource, createPfx, parsePfxDer, parsePfxPem } from "./pkcs/pfx.js";
|
|
10
10
|
import { CreatePkcs7CertBagDerResult, CreatePkcs7CertBagErrorCode, CreatePkcs7CertBagFailure, CreatePkcs7CertBagResult, CreatePkcs7SignedDataDerResult, CreatePkcs7SignedDataErrorCode, CreatePkcs7SignedDataFailure, CreatePkcs7SignedDataInput, CreatePkcs7SignedDataResult, ParsePkcs7CertBagResult, ParsePkcs7ErrorCode, ParsePkcs7Failure, ParsePkcs7SignedDataResult, ParsedPkcs7SignedData, ParsedPkcs7SignerInfo, Pkcs7CertBag, Pkcs7CertificateSource, Pkcs7SignedDataMaterial, Pkcs7Signer, VerifyPkcs7SignedDataFailure, VerifyPkcs7SignedDataResult, createPkcs7CertBagDer, createPkcs7CertBagPem, createPkcs7SignedDataDer, createPkcs7SignedDataPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, verifyPkcs7SignedData } from "./pkcs/pkcs7.js";
|
|
11
11
|
import { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CreateCertificateRevocationListInput, CrlCertificateSource, CrlSource, ParsedCertificateRevocationList, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListFailure, VerifyCertificateRevocationListResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListPem, validateCertificateRevocationList, verifyCertificateRevocationList } from "./revocation/crl.js";
|
|
12
|
-
import { CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspRequestMaterial, OcspRequestSource, OcspResponseMaterial, ParsedOcspCertId, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseFailure, VerifyOcspResponseResult, createOcspRequest, createOcspResponse, parseOcspRequestDer, parseOcspRequestPem, parseOcspResponseDer, parseOcspResponsePem, validateOcspResponse, verifyOcspResponse } from "./revocation/ocsp.js";
|
|
12
|
+
import { CreateOcspRequestInput, CreateOcspRequestItemInput, CreateOcspResponseInput, CreateOcspSingleResponseInput, OcspCertStatus, OcspCertificateSource, OcspRequestMaterial, OcspRequestSource, OcspResponseMaterial, ParsedOcspCertId, ParsedOcspRequest, ParsedOcspResponderId, ParsedOcspResponse, ParsedOcspSingleResponse, ValidateOcspResponseFailure, ValidateOcspResponseInput, ValidateOcspResponseResult, VerifyOcspResponseFailure, VerifyOcspResponseResult, createOcspRequest, createOcspResponse, hasOcspNoCheckExtension, parseOcspRequestDer, parseOcspRequestPem, parseOcspResponseDer, parseOcspResponsePem, validateOcspResponse, verifyOcspResponse } from "./revocation/ocsp.js";
|
|
13
13
|
import { CheckCertificateRevocationInput, CheckCertificateRevocationResult, ConfiguredOcspResponder, OcspResponderCandidate, OcspResponderSource, ResolveOcspResponderCandidatesInput, RevocationCertificateSource, RevocationCrlEvidenceInput, RevocationEvidenceInput, RevocationEvidenceKind, RevocationOcspEvidenceInput, RevocationStatus, checkCertificateRevocation, getCertificateOcspResponderUris, resolveOcspResponderCandidates } from "./revocation/revocation.js";
|
|
14
14
|
import { CertificateRevocationStatus, CheckChainRevocationInput, CheckChainRevocationResult, CheckChainRevocationValue, RevocationExecutionError, RevocationIndeterminateReason, RevocationPolicy, RevocationSource, checkChainRevocation } from "./revocation/chain.js";
|
|
15
15
|
import { DnsServiceIdentityInput, IpServiceIdentityInput, MatchServiceIdentityErrorCode, MatchServiceIdentityFailure, MatchServiceIdentityInput, MatchServiceIdentityResult, MatchServiceIdentitySuccess, ServiceIdentityInput, ServiceIdentityType, SrvServiceIdentityInput, UriServiceIdentityInput, VerifyServiceIdentityInput, matchCertificateServiceIdentity, matchServiceIdentity } from "./verify/identity.js";
|
|
16
16
|
import { InitialNameConstraintsInput } from "./verify/name-constraints.js";
|
|
17
17
|
import { PolicyValidationInput } from "./verify/policy.js";
|
|
18
|
-
import { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CertificateSource, ChainRevocationInput, CsrSource, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, TrustAnchor, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifyCertificateChainInput, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
|
|
18
|
+
import { BuildCandidatePathInput, BuildCandidatePathResult, CandidatePath, CertificateSource, ChainRevocationInput, CsrSource, EkuCheckFailure, EkuCheckPurpose, EkuCheckResult, TrustAnchor, VERIFY_ERROR_CODES, ValidateCandidatePathInput, ValidateCandidatePathResult, ValidateCandidatePathSuccess, ValidateForCaInput, ValidateForCodeSigningInput, ValidateForTlsClientInput, ValidateForTlsServerInput, VerifiedCertificateChain, VerifyCertificateChainInput, VerifyChainFailure, VerifyChainResult, VerifyErrorCode, VerifyFailureDetails, VerifyPurpose, VerifyRequestFailure, VerifyRequestResult, buildCandidatePath, checkExtendedKeyUsage, trustAnchorFromCertificate, validateCandidatePath, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, verifyCertificateChain, verifyCertificateSigningRequest } from "./verify/verify.js";
|
|
19
19
|
import { CertificateMaterial, CreateCertificateInput, CreateSelfSignedCertificateInput, SelfSignedCertificateResult, ValidityInput, createCertificate, createSelfSignedCertificate } from "./x509/certificate.js";
|
|
20
20
|
import { CreateCsrInput, CsrMaterial, createCertificateSigningRequest } from "./x509/csr.js";
|
|
21
|
-
export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs7CertBagDerResult, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataDerResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateInput, type CrlCertificateSource, type CrlSource, type CsrMaterial, type CsrSource, type DecodedExtensionMap, type DecodedExtensionValue, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type GeneralName, type GeneralSubtree, type ImportEcPublicKeyInput, type ImportEd25519PublicKeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaPublicKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderSource, type OcspResponseMaterial, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedRelativeDistinguishedName, type ParsedRevokedCertificate, type Pbes2EncryptionOptions, type Pbes2EncryptionScheme, type Pbes2Prf, type PemBlock, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs7CertBag, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PrivateKeyImportInput, type PublicKeyImportInput, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateReason, type RevocationOcspEvidenceInput, type RevocationPolicy, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaScheme, type SelfSignedCertificateResult, type ServiceIdentityInput, type ServiceIdentityType, type SrvServiceIdentityInput, type SubjectAltName, type TrustAnchor, type UriServiceIdentityInput, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifyCertificateChainInput, type VerifyCertificateRevocationListFailure, type VerifyCertificateRevocationListResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyOcspResponseFailure, type VerifyOcspResponseResult, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, type VerifyServiceIdentityInput, buildCandidatePath, categorizePemBlocks, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBagDer, createPkcs7CertBagPem, createPkcs7SignedDataDer, createPkcs7SignedDataPem, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, importEncryptedPkcs1Pem, importEncryptedPkcs8Der, importEncryptedPkcs8Pem, importEncryptedSec1Pem, importPkcs1Der, importPkcs1Pem, importPkcs8Base64, importPkcs8Der, importPkcs8Pem, importPrivateJwk, importPublicJwk, importSec1Der, importSec1Pem, importSpkiBase64, importSpkiDer, importSpkiPem, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificatePem, parseCertificateRevocationListDer, parseCertificateRevocationListPem, parseCertificateSigningRequestDer, parseCertificateSigningRequestPem, parseOcspRequestDer, parseOcspRequestPem, parseOcspResponseDer, parseOcspResponsePem, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationList, verifyCertificateSigningRequest, verifyOcspResponse, verifyPkcs7SignedData };
|
|
21
|
+
export { type AuthorityInformationAccess, type BasicConstraints, type BuildCandidatePathInput, type BuildCandidatePathResult, type CandidatePath, type CategorizedPemBlocks, type CertificateExtensionsInput, type CertificateMaterial, type CertificatePolicies, type CertificateRevocationListMaterial, type CertificateRevocationStatus, type CertificateSource, type ChainRevocationInput, type CheckCertificateRevocationAgainstCrlInput, type CheckCertificateRevocationAgainstCrlResult, type CheckCertificateRevocationInput, type CheckCertificateRevocationResult, type CheckChainRevocationInput, type CheckChainRevocationResult, type CheckChainRevocationValue, type ConfiguredOcspResponder, type CreateCertificateInput, type CreateCertificateRevocationListInput, type CreateCsrInput, type CreateOcspRequestInput, type CreateOcspRequestItemInput, type CreateOcspResponseInput, type CreateOcspSingleResponseInput, type CreatePfxErrorCode, type CreatePfxFailure, type CreatePfxInput, type CreatePfxResult, type CreatePkcs7CertBagDerResult, type CreatePkcs7CertBagErrorCode, type CreatePkcs7CertBagFailure, type CreatePkcs7CertBagResult, type CreatePkcs7SignedDataDerResult, type CreatePkcs7SignedDataErrorCode, type CreatePkcs7SignedDataFailure, type CreatePkcs7SignedDataInput, type CreatePkcs7SignedDataResult, type CreateSelfSignedCertificateInput, type CrlCertificateSource, type CrlSource, type CsrMaterial, type CsrSource, type DecodedExtensionMap, type DecodedExtensionValue, type DistributionPoint, type DistributionPointName, type DnsServiceIdentityInput, type EcKeyAlgorithmInput, type EcNamedCurve, type Ed25519KeyAlgorithmInput, type EkuCheckFailure, type EkuCheckPurpose, type EkuCheckResult, type EncryptedPkcs8Options, type ErrorResult, type ExtendedKeyUsage, type ExtensionDecoder, type ExtensionDecoderMap, type GeneralName, type GeneralSubtree, type ImportEcPublicKeyInput, type ImportEd25519PublicKeyInput, type ImportEncryptedKeyErrorCode, type ImportEncryptedKeyFailure, type ImportEncryptedKeyResult, type ImportKeyErrorCode, type ImportKeyFailure, type ImportKeyResult, type ImportRsaPublicKeyInput, type IndexedErrorResult, type IndexedMicro509Error, type InhibitAnyPolicy, type InitialNameConstraintsInput, type IpServiceIdentityInput, type IssuingDistributionPoint, type KeyAlgorithmInput, type KeyPairMaterial, type KeyUsage, type LegacyPemEncryptionOptions, type MatchServiceIdentityErrorCode, type MatchServiceIdentityFailure, type MatchServiceIdentityInput, type MatchServiceIdentityResult, type MatchServiceIdentitySuccess, type Micro509Error, type NameAttribute, type NameConstraintForm, type NameConstraints, type NameFieldKey, type NameInput, type NameObject, type OcspCertStatus, type OcspCertificateSource, type OcspRequestMaterial, type OcspRequestSource, type OcspResponderCandidate, type OcspResponderSource, type OcspResponseMaterial, type ParseCertificateErrorCode, type ParseCertificateFailure, type ParseCertificateResult, type ParseCertificateSigningRequestErrorCode, type ParseCertificateSigningRequestFailure, type ParseCertificateSigningRequestResult, type ParseOptions, type ParsePfxErrorCode, type ParsePfxFailure, type ParsePfxOptions, type ParsePfxResult, type ParsePkcs7CertBagResult, type ParsePkcs7ErrorCode, type ParsePkcs7Failure, type ParsePkcs7SignedDataResult, type ParsedBitFlags, type ParsedCertificate, type ParsedCertificateRevocationList, type ParsedCertificateSigningRequest, type ParsedDistributionPoint, type ParsedDistributionPointName, type ParsedExtension, type ParsedIssuingDistributionPoint, type ParsedName, type ParsedNameAttribute, type ParsedNameConstraintForm, type ParsedOcspCertId, type ParsedOcspRequest, type ParsedOcspResponderId, type ParsedOcspResponse, type ParsedOcspSingleResponse, type ParsedPfx, type ParsedPfxAttribute, type ParsedPfxBag, type ParsedPfxBagAttributes, type ParsedPkcs7SignedData, type ParsedPkcs7SignerInfo, type ParsedRelativeDistinguishedName, type ParsedRevokedCertificate, type Pbes2EncryptionOptions, type Pbes2EncryptionScheme, type Pbes2Prf, type PemBlock, type PfxBagAttributesInput, type PfxCertificateBagInput, type PfxCertificateSource, type PfxEncryptionOptions, type PfxMaterial, type PfxPrivateKeyBagInput, type PfxPrivateKeySource, type Pkcs7CertBag, type Pkcs7CertificateSource, type Pkcs7SignedDataMaterial, type Pkcs7Signer, type PolicyConstraints, type PolicyInformation, type PolicyMapping, type PolicyMappings, type PolicyQualifierInfo, type PolicyValidationInput, type PrivateKeyImportInput, type PublicKeyImportInput, type RelativeDistinguishedNameInput, type ResolveOcspResponderCandidatesInput, type Result, type ResultError, type RevocationCertificateSource, type RevocationCrlEvidenceInput, type RevocationEvidenceInput, type RevocationEvidenceKind, type RevocationExecutionError, type RevocationIndeterminateReason, type RevocationOcspEvidenceInput, type RevocationPolicy, type RevocationReason, type RevocationSource, type RevocationStatus, type RevokedCertificateInput, type RsaHash, type RsaKeyAlgorithmInput, type RsaScheme, type SelfSignedCertificateResult, type ServiceIdentityInput, type ServiceIdentityType, type SrvServiceIdentityInput, type SubjectAltName, type TrustAnchor, type UriServiceIdentityInput, VERIFY_ERROR_CODES, type ValidateCandidatePathInput, type ValidateCandidatePathResult, type ValidateCandidatePathSuccess, type ValidateCertificateRevocationListFailure, type ValidateCertificateRevocationListInput, type ValidateCertificateRevocationListResult, type ValidateForCaInput, type ValidateForCodeSigningInput, type ValidateForTlsClientInput, type ValidateForTlsServerInput, type ValidateOcspResponseFailure, type ValidateOcspResponseInput, type ValidateOcspResponseResult, type ValidityInput, type VerifiedCertificateChain, type VerifyCertificateChainInput, type VerifyCertificateRevocationListFailure, type VerifyCertificateRevocationListResult, type VerifyChainFailure, type VerifyChainResult, type VerifyErrorCode, type VerifyFailureDetails, type VerifyOcspResponseFailure, type VerifyOcspResponseResult, type VerifyPkcs7SignedDataFailure, type VerifyPkcs7SignedDataResult, type VerifyPurpose, type VerifyRequestFailure, type VerifyRequestResult, type VerifyServiceIdentityInput, buildCandidatePath, categorizePemBlocks, checkCertificateRevocation, checkCertificateRevocationAgainstCrl, checkChainRevocation, checkExtendedKeyUsage, createCertificate, createCertificateRevocationList, createCertificateSigningRequest, createOcspRequest, createOcspResponse, createPfx, createPkcs7CertBagDer, createPkcs7CertBagPem, createPkcs7SignedDataDer, createPkcs7SignedDataPem, createSelfSignedCertificate, decodeExtension, decodeExtensionMap, decodeExtensions, defineExtensionDecoder, defineExtensionDecoderMap, exportBinaryBase64, exportEncryptedPkcs1Pem, exportEncryptedPkcs8Der, exportEncryptedPkcs8Pem, exportEncryptedSec1Pem, exportPkcs1Der, exportPkcs1Pem, exportPkcs8Der, exportPkcs8Pem, exportPrivateJwk, exportPublicJwk, exportSec1Der, exportSec1Pem, exportSpkiDer, exportSpkiPem, findExtension, generateKeyPair, getCertificateOcspResponderUris, hasOcspNoCheckExtension, importEncryptedPkcs1Pem, importEncryptedPkcs8Der, importEncryptedPkcs8Pem, importEncryptedSec1Pem, importPkcs1Der, importPkcs1Pem, importPkcs8Base64, importPkcs8Der, importPkcs8Pem, importPrivateJwk, importPublicJwk, importSec1Der, importSec1Pem, importSpkiBase64, importSpkiDer, importSpkiPem, isCertificateRevoked, isResultError, matchCertificateServiceIdentity, matchServiceIdentity, parseCertificateChainPem, parseCertificateDer, parseCertificatePem, parseCertificateRevocationListDer, parseCertificateRevocationListPem, parseCertificateSigningRequestDer, parseCertificateSigningRequestPem, parseOcspRequestDer, parseOcspRequestPem, parseOcspResponseDer, parseOcspResponsePem, parsePfxDer, parsePfxPem, parsePkcs7CertBagDer, parsePkcs7CertBagPem, parsePkcs7SignedDataDer, parsePkcs7SignedDataPem, pemDecode, pemEncode, resolveOcspResponderCandidates, splitPemBlocks, trustAnchorFromCertificate, unwrap, unwrapOr, validateCandidatePath, validateCertificateRevocationList, validateForCa, validateForCodeSigning, validateForTlsClient, validateForTlsServer, validateOcspResponse, verifyCertificateChain, verifyCertificateRevocationList, verifyCertificateSigningRequest, verifyOcspResponse, verifyPkcs7SignedData };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{categorizePemBlocks as e,pemDecode as t,pemEncode as n,splitPemBlocks as r}from"./pem/pem.js";import{isResultError as i,unwrap as a,unwrapOr as o}from"./result/result.js";import{exportBinaryBase64 as s,exportEncryptedPkcs1Pem as c,exportEncryptedPkcs8Der as l,exportEncryptedPkcs8Pem as u,exportEncryptedSec1Pem as d,exportPkcs1Der as f,exportPkcs1Pem as p,exportPkcs8Der as m,exportPkcs8Pem as h,exportPrivateJwk as g,exportPublicJwk as _,exportSec1Der as v,exportSec1Pem as y,exportSpkiDer as b,exportSpkiPem as x,generateKeyPair as S,importEncryptedPkcs1Pem as C,importEncryptedPkcs8Der as w,importEncryptedPkcs8Pem as T,importEncryptedSec1Pem as E,importPkcs1Der as D,importPkcs1Pem as O,importPkcs8Base64 as k,importPkcs8Der as A,importPkcs8Pem as j,importPrivateJwk as M,importPublicJwk as N,importSec1Der as P,importSec1Pem as F,importSpkiBase64 as I,importSpkiDer as L,importSpkiPem as R}from"./keys/keys.js";import{decodeExtension as z,decodeExtensionMap as B,decodeExtensions as V,defineExtensionDecoder as H,defineExtensionDecoderMap as U,findExtension as W,parseCertificateChainPem as G,parseCertificateDer as K,parseCertificatePem as q,parseCertificateSigningRequestDer as J,parseCertificateSigningRequestPem as Y}from"./x509/parse.js";import{createPfx as X,parsePfxDer as Z,parsePfxPem as Q}from"./pkcs/pfx.js";import{createPkcs7CertBagDer as $,createPkcs7CertBagPem as ee,createPkcs7SignedDataDer as te,createPkcs7SignedDataPem as ne,parsePkcs7CertBagDer as re,parsePkcs7CertBagPem as ie,parsePkcs7SignedDataDer as ae,parsePkcs7SignedDataPem as oe,verifyPkcs7SignedData as se}from"./pkcs/pkcs7.js";import{checkCertificateRevocationAgainstCrl as ce,createCertificateRevocationList as le,isCertificateRevoked as ue,parseCertificateRevocationListDer as de,parseCertificateRevocationListPem as fe,validateCertificateRevocationList as pe,verifyCertificateRevocationList as me}from"./revocation/crl.js";import{checkChainRevocation as he}from"./revocation/chain.js";import{matchCertificateServiceIdentity as ge,matchServiceIdentity as _e}from"./verify/identity.js";import{
|
|
1
|
+
import{categorizePemBlocks as e,pemDecode as t,pemEncode as n,splitPemBlocks as r}from"./pem/pem.js";import{isResultError as i,unwrap as a,unwrapOr as o}from"./result/result.js";import{exportBinaryBase64 as s,exportEncryptedPkcs1Pem as c,exportEncryptedPkcs8Der as l,exportEncryptedPkcs8Pem as u,exportEncryptedSec1Pem as d,exportPkcs1Der as f,exportPkcs1Pem as p,exportPkcs8Der as m,exportPkcs8Pem as h,exportPrivateJwk as g,exportPublicJwk as _,exportSec1Der as v,exportSec1Pem as y,exportSpkiDer as b,exportSpkiPem as x,generateKeyPair as S,importEncryptedPkcs1Pem as C,importEncryptedPkcs8Der as w,importEncryptedPkcs8Pem as T,importEncryptedSec1Pem as E,importPkcs1Der as D,importPkcs1Pem as O,importPkcs8Base64 as k,importPkcs8Der as A,importPkcs8Pem as j,importPrivateJwk as M,importPublicJwk as N,importSec1Der as P,importSec1Pem as F,importSpkiBase64 as I,importSpkiDer as L,importSpkiPem as R}from"./keys/keys.js";import{decodeExtension as z,decodeExtensionMap as B,decodeExtensions as V,defineExtensionDecoder as H,defineExtensionDecoderMap as U,findExtension as W,parseCertificateChainPem as G,parseCertificateDer as K,parseCertificatePem as q,parseCertificateSigningRequestDer as J,parseCertificateSigningRequestPem as Y}from"./x509/parse.js";import{createPfx as X,parsePfxDer as Z,parsePfxPem as Q}from"./pkcs/pfx.js";import{createPkcs7CertBagDer as $,createPkcs7CertBagPem as ee,createPkcs7SignedDataDer as te,createPkcs7SignedDataPem as ne,parsePkcs7CertBagDer as re,parsePkcs7CertBagPem as ie,parsePkcs7SignedDataDer as ae,parsePkcs7SignedDataPem as oe,verifyPkcs7SignedData as se}from"./pkcs/pkcs7.js";import{checkCertificateRevocationAgainstCrl as ce,createCertificateRevocationList as le,isCertificateRevoked as ue,parseCertificateRevocationListDer as de,parseCertificateRevocationListPem as fe,validateCertificateRevocationList as pe,verifyCertificateRevocationList as me}from"./revocation/crl.js";import{checkChainRevocation as he}from"./revocation/chain.js";import{matchCertificateServiceIdentity as ge,matchServiceIdentity as _e}from"./verify/identity.js";import{VERIFY_ERROR_CODES as ve,buildCandidatePath as ye,checkExtendedKeyUsage as be,trustAnchorFromCertificate as xe,validateCandidatePath as Se,validateForCa as Ce,validateForCodeSigning as we,validateForTlsClient as Te,validateForTlsServer as Ee,verifyCertificateChain as De,verifyCertificateSigningRequest as Oe}from"./verify/verify.js";import{createOcspRequest as ke,createOcspResponse as Ae,hasOcspNoCheckExtension as je,parseOcspRequestDer as Me,parseOcspRequestPem as Ne,parseOcspResponseDer as Pe,parseOcspResponsePem as Fe,validateOcspResponse as Ie,verifyOcspResponse as Le}from"./revocation/ocsp.js";import{checkCertificateRevocation as Re,getCertificateOcspResponderUris as ze,resolveOcspResponderCandidates as Be}from"./revocation/revocation.js";import{createCertificate as Ve,createSelfSignedCertificate as He}from"./x509/certificate.js";import{createCertificateSigningRequest as Ue}from"./x509/csr.js";export{ve as VERIFY_ERROR_CODES,ye as buildCandidatePath,e as categorizePemBlocks,Re as checkCertificateRevocation,ce as checkCertificateRevocationAgainstCrl,he as checkChainRevocation,be as checkExtendedKeyUsage,Ve as createCertificate,le as createCertificateRevocationList,Ue as createCertificateSigningRequest,ke as createOcspRequest,Ae as createOcspResponse,X as createPfx,$ as createPkcs7CertBagDer,ee as createPkcs7CertBagPem,te as createPkcs7SignedDataDer,ne as createPkcs7SignedDataPem,He as createSelfSignedCertificate,z as decodeExtension,B as decodeExtensionMap,V as decodeExtensions,H as defineExtensionDecoder,U as defineExtensionDecoderMap,s as exportBinaryBase64,c as exportEncryptedPkcs1Pem,l as exportEncryptedPkcs8Der,u as exportEncryptedPkcs8Pem,d as exportEncryptedSec1Pem,f as exportPkcs1Der,p as exportPkcs1Pem,m as exportPkcs8Der,h as exportPkcs8Pem,g as exportPrivateJwk,_ as exportPublicJwk,v as exportSec1Der,y as exportSec1Pem,b as exportSpkiDer,x as exportSpkiPem,W as findExtension,S as generateKeyPair,ze as getCertificateOcspResponderUris,je as hasOcspNoCheckExtension,C as importEncryptedPkcs1Pem,w as importEncryptedPkcs8Der,T as importEncryptedPkcs8Pem,E as importEncryptedSec1Pem,D as importPkcs1Der,O as importPkcs1Pem,k as importPkcs8Base64,A as importPkcs8Der,j as importPkcs8Pem,M as importPrivateJwk,N as importPublicJwk,P as importSec1Der,F as importSec1Pem,I as importSpkiBase64,L as importSpkiDer,R as importSpkiPem,ue as isCertificateRevoked,i as isResultError,ge as matchCertificateServiceIdentity,_e as matchServiceIdentity,G as parseCertificateChainPem,K as parseCertificateDer,q as parseCertificatePem,de as parseCertificateRevocationListDer,fe as parseCertificateRevocationListPem,J as parseCertificateSigningRequestDer,Y as parseCertificateSigningRequestPem,Me as parseOcspRequestDer,Ne as parseOcspRequestPem,Pe as parseOcspResponseDer,Fe as parseOcspResponsePem,Z as parsePfxDer,Q as parsePfxPem,re as parsePkcs7CertBagDer,ie as parsePkcs7CertBagPem,ae as parsePkcs7SignedDataDer,oe as parsePkcs7SignedDataPem,t as pemDecode,n as pemEncode,Be as resolveOcspResponderCandidates,r as splitPemBlocks,xe as trustAnchorFromCertificate,a as unwrap,o as unwrapOr,Se as validateCandidatePath,pe as validateCertificateRevocationList,Ce as validateForCa,we as validateForCodeSigning,Te as validateForTlsClient,Ee as validateForTlsServer,Ie as validateOcspResponse,De as verifyCertificateChain,me as verifyCertificateRevocationList,Oe as verifyCertificateSigningRequest,Le as verifyOcspResponse,se as verifyPkcs7SignedData};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={commonName:`2.5.4.3`,surname:`2.5.4.4`,serialNumber:`2.5.4.5`,countryName:`2.5.4.6`,localityName:`2.5.4.7`,stateOrProvinceName:`2.5.4.8`,streetAddress:`2.5.4.9`,organizationName:`2.5.4.10`,organizationalUnitName:`2.5.4.11`,title:`2.5.4.12`,givenName:`2.5.4.42`,emailAddress:`1.2.840.113549.1.9.1`,cmsContentType:`1.2.840.113549.1.9.3`,cmsMessageDigest:`1.2.840.113549.1.9.4`,extensionRequest:`1.2.840.113549.1.9.14`,pkcs7Data:`1.2.840.113549.1.7.1`,pkcs7SignedData:`1.2.840.113549.1.7.2`,pkcs7EncryptedData:`1.2.840.113549.1.7.6`,pkcs12KeyBag:`1.2.840.113549.1.12.10.1.1`,pkcs12CertBag:`1.2.840.113549.1.12.10.1.3`,x509CertificateBagType:`1.2.840.113549.1.9.22.1`,friendlyName:`1.2.840.113549.1.9.20`,localKeyId:`1.2.840.113549.1.9.21`,pbes2:`1.2.840.113549.1.5.13`,pbkdf2:`1.2.840.113549.1.5.12`,mgf1:`1.2.840.113549.1.1.8`,hmacWithSHA1:`1.2.840.113549.2.7`,hmacWithSHA256:`1.2.840.113549.2.9`,aes128Cbc:`2.16.840.1.101.3.4.1.2`,aes192Cbc:`2.16.840.1.101.3.4.1.22`,aes256Cbc:`2.16.840.1.101.3.4.1.42`,rsaEncryption:`1.2.840.113549.1.1.1`,sha1WithRSAEncryption:`1.2.840.113549.1.1.5`,rsassaPss:`1.2.840.113549.1.1.10`,sha256WithRSAEncryption:`1.2.840.113549.1.1.11`,sha384WithRSAEncryption:`1.2.840.113549.1.1.12`,sha512WithRSAEncryption:`1.2.840.113549.1.1.13`,ecPublicKey:`1.2.840.10045.2.1`,ecdsaWithSHA1:`1.2.840.10045.4.1`,ecdsaWithSHA224:`1.2.840.10045.4.3.1`,ecdsaWithSHA256:`1.2.840.10045.4.3.2`,ecdsaWithSHA384:`1.2.840.10045.4.3.3`,ecdsaWithSHA512:`1.2.840.10045.4.3.4`,prime256v1:`1.2.840.10045.3.1.7`,secp384r1:`1.3.132.0.34`,secp521r1:`1.3.132.0.35`,ed25519:`1.3.101.112`,subjectKeyIdentifier:`2.5.29.14`,keyUsage:`2.5.29.15`,subjectAltName:`2.5.29.17`,nameConstraints:`2.5.29.30`,certificatePolicies:`2.5.29.32`,policyMappings:`2.5.29.33`,cRLNumber:`2.5.29.20`,cRLReason:`2.5.29.21`,invalidityDate:`2.5.29.24`,certificateIssuer:`2.5.29.29`,issuingDistributionPoint:`2.5.29.28`,deltaCRLIndicator:`2.5.29.27`,basicConstraints:`2.5.29.19`,policyConstraints:`2.5.29.36`,cRLDistributionPoints:`2.5.29.31`,freshestCRL:`2.5.29.46`,inhibitAnyPolicy:`2.5.29.54`,extendedKeyUsage:`2.5.29.37`,authorityKeyIdentifier:`2.5.29.35`,anyPolicy:`2.5.29.32.0`,authorityInfoAccess:`1.3.6.1.5.5.7.1.1`,idOnDnsSrv:`1.3.6.1.5.5.7.8.7`,cpsPolicyQualifier:`1.3.6.1.5.5.7.2.1`,userNoticePolicyQualifier:`1.3.6.1.5.5.7.2.2`,ocspAccessMethod:`1.3.6.1.5.5.7.48.1`,caIssuersAccessMethod:`1.3.6.1.5.5.7.48.2`,ocspBasicResponse:`1.3.6.1.5.5.7.48.1.1`,ocspNonce:`1.3.6.1.5.5.7.48.1.2`,sha1:`1.3.14.3.2.26`,sha256:`2.16.840.1.101.3.4.2.1`,sha384:`2.16.840.1.101.3.4.2.2`,sha512:`2.16.840.1.101.3.4.2.3`,serverAuth:`1.3.6.1.5.5.7.3.1`,clientAuth:`1.3.6.1.5.5.7.3.2`,codeSigning:`1.3.6.1.5.5.7.3.3`,emailProtection:`1.3.6.1.5.5.7.3.4`,timeStamping:`1.3.6.1.5.5.7.3.8`,ocspSigning:`1.3.6.1.5.5.7.3.9`};export{e as OIDS};
|
|
1
|
+
const e={commonName:`2.5.4.3`,surname:`2.5.4.4`,serialNumber:`2.5.4.5`,countryName:`2.5.4.6`,localityName:`2.5.4.7`,stateOrProvinceName:`2.5.4.8`,streetAddress:`2.5.4.9`,organizationName:`2.5.4.10`,organizationalUnitName:`2.5.4.11`,title:`2.5.4.12`,givenName:`2.5.4.42`,emailAddress:`1.2.840.113549.1.9.1`,cmsContentType:`1.2.840.113549.1.9.3`,cmsMessageDigest:`1.2.840.113549.1.9.4`,extensionRequest:`1.2.840.113549.1.9.14`,pkcs7Data:`1.2.840.113549.1.7.1`,pkcs7SignedData:`1.2.840.113549.1.7.2`,pkcs7EncryptedData:`1.2.840.113549.1.7.6`,pkcs12KeyBag:`1.2.840.113549.1.12.10.1.1`,pkcs12CertBag:`1.2.840.113549.1.12.10.1.3`,x509CertificateBagType:`1.2.840.113549.1.9.22.1`,friendlyName:`1.2.840.113549.1.9.20`,localKeyId:`1.2.840.113549.1.9.21`,pbes2:`1.2.840.113549.1.5.13`,pbkdf2:`1.2.840.113549.1.5.12`,mgf1:`1.2.840.113549.1.1.8`,hmacWithSHA1:`1.2.840.113549.2.7`,hmacWithSHA256:`1.2.840.113549.2.9`,aes128Cbc:`2.16.840.1.101.3.4.1.2`,aes192Cbc:`2.16.840.1.101.3.4.1.22`,aes256Cbc:`2.16.840.1.101.3.4.1.42`,rsaEncryption:`1.2.840.113549.1.1.1`,sha1WithRSAEncryption:`1.2.840.113549.1.1.5`,rsassaPss:`1.2.840.113549.1.1.10`,sha256WithRSAEncryption:`1.2.840.113549.1.1.11`,sha384WithRSAEncryption:`1.2.840.113549.1.1.12`,sha512WithRSAEncryption:`1.2.840.113549.1.1.13`,ecPublicKey:`1.2.840.10045.2.1`,ecdsaWithSHA1:`1.2.840.10045.4.1`,ecdsaWithSHA224:`1.2.840.10045.4.3.1`,ecdsaWithSHA256:`1.2.840.10045.4.3.2`,ecdsaWithSHA384:`1.2.840.10045.4.3.3`,ecdsaWithSHA512:`1.2.840.10045.4.3.4`,prime256v1:`1.2.840.10045.3.1.7`,secp384r1:`1.3.132.0.34`,secp521r1:`1.3.132.0.35`,ed25519:`1.3.101.112`,subjectKeyIdentifier:`2.5.29.14`,keyUsage:`2.5.29.15`,subjectAltName:`2.5.29.17`,nameConstraints:`2.5.29.30`,certificatePolicies:`2.5.29.32`,policyMappings:`2.5.29.33`,cRLNumber:`2.5.29.20`,cRLReason:`2.5.29.21`,invalidityDate:`2.5.29.24`,certificateIssuer:`2.5.29.29`,issuingDistributionPoint:`2.5.29.28`,deltaCRLIndicator:`2.5.29.27`,basicConstraints:`2.5.29.19`,policyConstraints:`2.5.29.36`,cRLDistributionPoints:`2.5.29.31`,freshestCRL:`2.5.29.46`,inhibitAnyPolicy:`2.5.29.54`,extendedKeyUsage:`2.5.29.37`,authorityKeyIdentifier:`2.5.29.35`,anyPolicy:`2.5.29.32.0`,authorityInfoAccess:`1.3.6.1.5.5.7.1.1`,idOnDnsSrv:`1.3.6.1.5.5.7.8.7`,cpsPolicyQualifier:`1.3.6.1.5.5.7.2.1`,userNoticePolicyQualifier:`1.3.6.1.5.5.7.2.2`,ocspAccessMethod:`1.3.6.1.5.5.7.48.1`,caIssuersAccessMethod:`1.3.6.1.5.5.7.48.2`,ocspBasicResponse:`1.3.6.1.5.5.7.48.1.1`,ocspNonce:`1.3.6.1.5.5.7.48.1.2`,ocspNoCheck:`1.3.6.1.5.5.7.48.1.5`,sha1:`1.3.14.3.2.26`,sha256:`2.16.840.1.101.3.4.2.1`,sha384:`2.16.840.1.101.3.4.2.2`,sha512:`2.16.840.1.101.3.4.2.3`,serverAuth:`1.3.6.1.5.5.7.3.1`,clientAuth:`1.3.6.1.5.5.7.3.2`,codeSigning:`1.3.6.1.5.5.7.3.3`,emailProtection:`1.3.6.1.5.5.7.3.4`,timeStamping:`1.3.6.1.5.5.7.3.8`,ocspSigning:`1.3.6.1.5.5.7.3.9`};export{e as OIDS};
|
|
2
2
|
//# sourceMappingURL=oids.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oids.js","names":[],"sources":["../../../src/internal/asn1/oids.ts"],"sourcesContent":["/**\n * Centralized ASN.1 object identifier registry referenced by create, parse,\n * verify, and container modules.\n *\n * All OIDs are dotted-decimal string constants keyed by their common short name.\n *\n * @module\n */\n\n/**\n * Dotted-decimal OID constants for X.500 attributes, PKCS algorithms,\n * X.509v3 extensions, EKU purposes, hash algorithms, and PKIX access methods.\n */\nconst OIDS = {\n\tcommonName: '2.5.4.3',\n\tsurname: '2.5.4.4',\n\tserialNumber: '2.5.4.5',\n\tcountryName: '2.5.4.6',\n\tlocalityName: '2.5.4.7',\n\tstateOrProvinceName: '2.5.4.8',\n\tstreetAddress: '2.5.4.9',\n\torganizationName: '2.5.4.10',\n\torganizationalUnitName: '2.5.4.11',\n\ttitle: '2.5.4.12',\n\tgivenName: '2.5.4.42',\n\temailAddress: '1.2.840.113549.1.9.1',\n\tcmsContentType: '1.2.840.113549.1.9.3',\n\tcmsMessageDigest: '1.2.840.113549.1.9.4',\n\textensionRequest: '1.2.840.113549.1.9.14',\n\tpkcs7Data: '1.2.840.113549.1.7.1',\n\tpkcs7SignedData: '1.2.840.113549.1.7.2',\n\tpkcs7EncryptedData: '1.2.840.113549.1.7.6',\n\tpkcs12KeyBag: '1.2.840.113549.1.12.10.1.1',\n\tpkcs12CertBag: '1.2.840.113549.1.12.10.1.3',\n\tx509CertificateBagType: '1.2.840.113549.1.9.22.1',\n\tfriendlyName: '1.2.840.113549.1.9.20',\n\tlocalKeyId: '1.2.840.113549.1.9.21',\n\tpbes2: '1.2.840.113549.1.5.13',\n\tpbkdf2: '1.2.840.113549.1.5.12',\n\tmgf1: '1.2.840.113549.1.1.8',\n\thmacWithSHA1: '1.2.840.113549.2.7',\n\thmacWithSHA256: '1.2.840.113549.2.9',\n\taes128Cbc: '2.16.840.1.101.3.4.1.2',\n\taes192Cbc: '2.16.840.1.101.3.4.1.22',\n\taes256Cbc: '2.16.840.1.101.3.4.1.42',\n\trsaEncryption: '1.2.840.113549.1.1.1',\n\tsha1WithRSAEncryption: '1.2.840.113549.1.1.5',\n\trsassaPss: '1.2.840.113549.1.1.10',\n\tsha256WithRSAEncryption: '1.2.840.113549.1.1.11',\n\tsha384WithRSAEncryption: '1.2.840.113549.1.1.12',\n\tsha512WithRSAEncryption: '1.2.840.113549.1.1.13',\n\tecPublicKey: '1.2.840.10045.2.1',\n\tecdsaWithSHA1: '1.2.840.10045.4.1',\n\tecdsaWithSHA224: '1.2.840.10045.4.3.1',\n\tecdsaWithSHA256: '1.2.840.10045.4.3.2',\n\tecdsaWithSHA384: '1.2.840.10045.4.3.3',\n\tecdsaWithSHA512: '1.2.840.10045.4.3.4',\n\tprime256v1: '1.2.840.10045.3.1.7',\n\tsecp384r1: '1.3.132.0.34',\n\tsecp521r1: '1.3.132.0.35',\n\ted25519: '1.3.101.112',\n\tsubjectKeyIdentifier: '2.5.29.14',\n\tkeyUsage: '2.5.29.15',\n\tsubjectAltName: '2.5.29.17',\n\tnameConstraints: '2.5.29.30',\n\tcertificatePolicies: '2.5.29.32',\n\tpolicyMappings: '2.5.29.33',\n\tcRLNumber: '2.5.29.20',\n\tcRLReason: '2.5.29.21',\n\tinvalidityDate: '2.5.29.24',\n\tcertificateIssuer: '2.5.29.29',\n\tissuingDistributionPoint: '2.5.29.28',\n\tdeltaCRLIndicator: '2.5.29.27',\n\tbasicConstraints: '2.5.29.19',\n\tpolicyConstraints: '2.5.29.36',\n\tcRLDistributionPoints: '2.5.29.31',\n\tfreshestCRL: '2.5.29.46',\n\tinhibitAnyPolicy: '2.5.29.54',\n\textendedKeyUsage: '2.5.29.37',\n\tauthorityKeyIdentifier: '2.5.29.35',\n\tanyPolicy: '2.5.29.32.0',\n\tauthorityInfoAccess: '1.3.6.1.5.5.7.1.1',\n\tidOnDnsSrv: '1.3.6.1.5.5.7.8.7',\n\tcpsPolicyQualifier: '1.3.6.1.5.5.7.2.1',\n\tuserNoticePolicyQualifier: '1.3.6.1.5.5.7.2.2',\n\tocspAccessMethod: '1.3.6.1.5.5.7.48.1',\n\tcaIssuersAccessMethod: '1.3.6.1.5.5.7.48.2',\n\tocspBasicResponse: '1.3.6.1.5.5.7.48.1.1',\n\tocspNonce: '1.3.6.1.5.5.7.48.1.2',\n\tsha1: '1.3.14.3.2.26',\n\tsha256: '2.16.840.1.101.3.4.2.1',\n\tsha384: '2.16.840.1.101.3.4.2.2',\n\tsha512: '2.16.840.1.101.3.4.2.3',\n\tserverAuth: '1.3.6.1.5.5.7.3.1',\n\tclientAuth: '1.3.6.1.5.5.7.3.2',\n\tcodeSigning: '1.3.6.1.5.5.7.3.3',\n\temailProtection: '1.3.6.1.5.5.7.3.4',\n\ttimeStamping: '1.3.6.1.5.5.7.3.8',\n\tocspSigning: '1.3.6.1.5.5.7.3.9',\n} as const;\n\nexport { OIDS };\n"],"mappings":"AAaA,MAAM,EAAO,CACZ,WAAY,UACZ,QAAS,UACT,aAAc,UACd,YAAa,UACb,aAAc,UACd,oBAAqB,UACrB,cAAe,UACf,iBAAkB,WAClB,uBAAwB,WACxB,MAAO,WACP,UAAW,WACX,aAAc,uBACd,eAAgB,uBAChB,iBAAkB,uBAClB,iBAAkB,wBAClB,UAAW,uBACX,gBAAiB,uBACjB,mBAAoB,uBACpB,aAAc,6BACd,cAAe,6BACf,uBAAwB,0BACxB,aAAc,wBACd,WAAY,wBACZ,MAAO,wBACP,OAAQ,wBACR,KAAM,uBACN,aAAc,qBACd,eAAgB,qBAChB,UAAW,yBACX,UAAW,0BACX,UAAW,0BACX,cAAe,uBACf,sBAAuB,uBACvB,UAAW,wBACX,wBAAyB,wBACzB,wBAAyB,wBACzB,wBAAyB,wBACzB,YAAa,oBACb,cAAe,oBACf,gBAAiB,sBACjB,gBAAiB,sBACjB,gBAAiB,sBACjB,gBAAiB,sBACjB,WAAY,sBACZ,UAAW,eACX,UAAW,eACX,QAAS,cACT,qBAAsB,YACtB,SAAU,YACV,eAAgB,YAChB,gBAAiB,YACjB,oBAAqB,YACrB,eAAgB,YAChB,UAAW,YACX,UAAW,YACX,eAAgB,YAChB,kBAAmB,YACnB,yBAA0B,YAC1B,kBAAmB,YACnB,iBAAkB,YAClB,kBAAmB,YACnB,sBAAuB,YACvB,YAAa,YACb,iBAAkB,YAClB,iBAAkB,YAClB,uBAAwB,YACxB,UAAW,cACX,oBAAqB,oBACrB,WAAY,oBACZ,mBAAoB,oBACpB,0BAA2B,oBAC3B,iBAAkB,qBAClB,sBAAuB,qBACvB,kBAAmB,uBACnB,UAAW,uBACX,KAAM,gBACN,OAAQ,yBACR,OAAQ,yBACR,OAAQ,yBACR,WAAY,oBACZ,WAAY,oBACZ,YAAa,oBACb,gBAAiB,oBACjB,aAAc,oBACd,YAAa,mBACd"}
|
|
1
|
+
{"version":3,"file":"oids.js","names":[],"sources":["../../../src/internal/asn1/oids.ts"],"sourcesContent":["/**\n * Centralized ASN.1 object identifier registry referenced by create, parse,\n * verify, and container modules.\n *\n * All OIDs are dotted-decimal string constants keyed by their common short name.\n *\n * @module\n */\n\n/**\n * Dotted-decimal OID constants for X.500 attributes, PKCS algorithms,\n * X.509v3 extensions, EKU purposes, hash algorithms, and PKIX access methods.\n */\nconst OIDS = {\n\tcommonName: '2.5.4.3',\n\tsurname: '2.5.4.4',\n\tserialNumber: '2.5.4.5',\n\tcountryName: '2.5.4.6',\n\tlocalityName: '2.5.4.7',\n\tstateOrProvinceName: '2.5.4.8',\n\tstreetAddress: '2.5.4.9',\n\torganizationName: '2.5.4.10',\n\torganizationalUnitName: '2.5.4.11',\n\ttitle: '2.5.4.12',\n\tgivenName: '2.5.4.42',\n\temailAddress: '1.2.840.113549.1.9.1',\n\tcmsContentType: '1.2.840.113549.1.9.3',\n\tcmsMessageDigest: '1.2.840.113549.1.9.4',\n\textensionRequest: '1.2.840.113549.1.9.14',\n\tpkcs7Data: '1.2.840.113549.1.7.1',\n\tpkcs7SignedData: '1.2.840.113549.1.7.2',\n\tpkcs7EncryptedData: '1.2.840.113549.1.7.6',\n\tpkcs12KeyBag: '1.2.840.113549.1.12.10.1.1',\n\tpkcs12CertBag: '1.2.840.113549.1.12.10.1.3',\n\tx509CertificateBagType: '1.2.840.113549.1.9.22.1',\n\tfriendlyName: '1.2.840.113549.1.9.20',\n\tlocalKeyId: '1.2.840.113549.1.9.21',\n\tpbes2: '1.2.840.113549.1.5.13',\n\tpbkdf2: '1.2.840.113549.1.5.12',\n\tmgf1: '1.2.840.113549.1.1.8',\n\thmacWithSHA1: '1.2.840.113549.2.7',\n\thmacWithSHA256: '1.2.840.113549.2.9',\n\taes128Cbc: '2.16.840.1.101.3.4.1.2',\n\taes192Cbc: '2.16.840.1.101.3.4.1.22',\n\taes256Cbc: '2.16.840.1.101.3.4.1.42',\n\trsaEncryption: '1.2.840.113549.1.1.1',\n\tsha1WithRSAEncryption: '1.2.840.113549.1.1.5',\n\trsassaPss: '1.2.840.113549.1.1.10',\n\tsha256WithRSAEncryption: '1.2.840.113549.1.1.11',\n\tsha384WithRSAEncryption: '1.2.840.113549.1.1.12',\n\tsha512WithRSAEncryption: '1.2.840.113549.1.1.13',\n\tecPublicKey: '1.2.840.10045.2.1',\n\tecdsaWithSHA1: '1.2.840.10045.4.1',\n\tecdsaWithSHA224: '1.2.840.10045.4.3.1',\n\tecdsaWithSHA256: '1.2.840.10045.4.3.2',\n\tecdsaWithSHA384: '1.2.840.10045.4.3.3',\n\tecdsaWithSHA512: '1.2.840.10045.4.3.4',\n\tprime256v1: '1.2.840.10045.3.1.7',\n\tsecp384r1: '1.3.132.0.34',\n\tsecp521r1: '1.3.132.0.35',\n\ted25519: '1.3.101.112',\n\tsubjectKeyIdentifier: '2.5.29.14',\n\tkeyUsage: '2.5.29.15',\n\tsubjectAltName: '2.5.29.17',\n\tnameConstraints: '2.5.29.30',\n\tcertificatePolicies: '2.5.29.32',\n\tpolicyMappings: '2.5.29.33',\n\tcRLNumber: '2.5.29.20',\n\tcRLReason: '2.5.29.21',\n\tinvalidityDate: '2.5.29.24',\n\tcertificateIssuer: '2.5.29.29',\n\tissuingDistributionPoint: '2.5.29.28',\n\tdeltaCRLIndicator: '2.5.29.27',\n\tbasicConstraints: '2.5.29.19',\n\tpolicyConstraints: '2.5.29.36',\n\tcRLDistributionPoints: '2.5.29.31',\n\tfreshestCRL: '2.5.29.46',\n\tinhibitAnyPolicy: '2.5.29.54',\n\textendedKeyUsage: '2.5.29.37',\n\tauthorityKeyIdentifier: '2.5.29.35',\n\tanyPolicy: '2.5.29.32.0',\n\tauthorityInfoAccess: '1.3.6.1.5.5.7.1.1',\n\tidOnDnsSrv: '1.3.6.1.5.5.7.8.7',\n\tcpsPolicyQualifier: '1.3.6.1.5.5.7.2.1',\n\tuserNoticePolicyQualifier: '1.3.6.1.5.5.7.2.2',\n\tocspAccessMethod: '1.3.6.1.5.5.7.48.1',\n\tcaIssuersAccessMethod: '1.3.6.1.5.5.7.48.2',\n\tocspBasicResponse: '1.3.6.1.5.5.7.48.1.1',\n\tocspNonce: '1.3.6.1.5.5.7.48.1.2',\n\tocspNoCheck: '1.3.6.1.5.5.7.48.1.5',\n\tsha1: '1.3.14.3.2.26',\n\tsha256: '2.16.840.1.101.3.4.2.1',\n\tsha384: '2.16.840.1.101.3.4.2.2',\n\tsha512: '2.16.840.1.101.3.4.2.3',\n\tserverAuth: '1.3.6.1.5.5.7.3.1',\n\tclientAuth: '1.3.6.1.5.5.7.3.2',\n\tcodeSigning: '1.3.6.1.5.5.7.3.3',\n\temailProtection: '1.3.6.1.5.5.7.3.4',\n\ttimeStamping: '1.3.6.1.5.5.7.3.8',\n\tocspSigning: '1.3.6.1.5.5.7.3.9',\n} as const;\n\nexport { OIDS };\n"],"mappings":"AAaA,MAAM,EAAO,CACZ,WAAY,UACZ,QAAS,UACT,aAAc,UACd,YAAa,UACb,aAAc,UACd,oBAAqB,UACrB,cAAe,UACf,iBAAkB,WAClB,uBAAwB,WACxB,MAAO,WACP,UAAW,WACX,aAAc,uBACd,eAAgB,uBAChB,iBAAkB,uBAClB,iBAAkB,wBAClB,UAAW,uBACX,gBAAiB,uBACjB,mBAAoB,uBACpB,aAAc,6BACd,cAAe,6BACf,uBAAwB,0BACxB,aAAc,wBACd,WAAY,wBACZ,MAAO,wBACP,OAAQ,wBACR,KAAM,uBACN,aAAc,qBACd,eAAgB,qBAChB,UAAW,yBACX,UAAW,0BACX,UAAW,0BACX,cAAe,uBACf,sBAAuB,uBACvB,UAAW,wBACX,wBAAyB,wBACzB,wBAAyB,wBACzB,wBAAyB,wBACzB,YAAa,oBACb,cAAe,oBACf,gBAAiB,sBACjB,gBAAiB,sBACjB,gBAAiB,sBACjB,gBAAiB,sBACjB,WAAY,sBACZ,UAAW,eACX,UAAW,eACX,QAAS,cACT,qBAAsB,YACtB,SAAU,YACV,eAAgB,YAChB,gBAAiB,YACjB,oBAAqB,YACrB,eAAgB,YAChB,UAAW,YACX,UAAW,YACX,eAAgB,YAChB,kBAAmB,YACnB,yBAA0B,YAC1B,kBAAmB,YACnB,iBAAkB,YAClB,kBAAmB,YACnB,sBAAuB,YACvB,YAAa,YACb,iBAAkB,YAClB,iBAAkB,YAClB,uBAAwB,YACxB,UAAW,cACX,oBAAqB,oBACrB,WAAY,oBACZ,mBAAoB,oBACpB,0BAA2B,oBAC3B,iBAAkB,qBAClB,sBAAuB,qBACvB,kBAAmB,uBACnB,UAAW,uBACX,YAAa,uBACb,KAAM,gBACN,OAAQ,yBACR,OAAQ,yBACR,OAAQ,yBACR,WAAY,oBACZ,WAAY,oBACZ,YAAa,oBACb,gBAAiB,oBACjB,aAAc,oBACd,YAAa,mBACd"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ParsedCertificate } from "../x509/parse.js";
|
|
2
2
|
import { CrlSource, RevocationReason } from "./crl.js";
|
|
3
|
+
import { OcspResponderRevocationPolicy } from "./ocsp.js";
|
|
3
4
|
|
|
4
5
|
//#region src/revocation/chain.d.ts
|
|
5
6
|
/**
|
|
@@ -12,7 +13,7 @@ type CertificateSource = string | Uint8Array | ParsedCertificate;
|
|
|
12
13
|
/**
|
|
13
14
|
* OCSP response in any supported format.
|
|
14
15
|
*
|
|
15
|
-
* Accepts PEM string or DER bytes.
|
|
16
|
+
* Accepts PEM string or DER bytes. Used for
|
|
16
17
|
* {@linkcode CheckChainRevocationInput.ocspResponses}.
|
|
17
18
|
*/
|
|
18
19
|
type OcspResponseSource = string | Uint8Array;
|
|
@@ -33,11 +34,24 @@ interface RevocationPolicy {
|
|
|
33
34
|
/**
|
|
34
35
|
* Evidence preference when multiple sources are available.
|
|
35
36
|
*
|
|
36
|
-
*
|
|
37
|
+
* Both evidence kinds are always evaluated, and a validated `revoked`
|
|
38
|
+
* verdict from either source wins regardless of preference (fail-closed).
|
|
39
|
+
* Preference only decides which source's `good` verdict is reported when
|
|
40
|
+
* both yield one.
|
|
41
|
+
*
|
|
42
|
+
* - `'best-available'`: the source with the fresher evidence — the later
|
|
43
|
+
* `thisUpdate` on the validated OCSP entry or CRL — is reported; ties
|
|
44
|
+
* favor OCSP (default)
|
|
37
45
|
* - `'ocsp'`: prefer OCSP over CRL
|
|
38
46
|
* - `'crl'`: prefer CRL over OCSP
|
|
39
47
|
*/
|
|
40
48
|
readonly prefer?: "ocsp" | "crl" | "best-available";
|
|
49
|
+
/**
|
|
50
|
+
* Revocation policy for delegated OCSP responder certificates
|
|
51
|
+
* (RFC 6960 §4.2.2.2.1). Supplied CRLs double as responder revocation
|
|
52
|
+
* evidence. Defaults to `'honor-nocheck'`.
|
|
53
|
+
*/
|
|
54
|
+
readonly ocspResponderRevocation?: OcspResponderRevocationPolicy;
|
|
41
55
|
}
|
|
42
56
|
/** Input for {@linkcode checkChainRevocation}. */
|
|
43
57
|
interface CheckChainRevocationInput {
|
|
@@ -49,6 +63,12 @@ interface CheckChainRevocationInput {
|
|
|
49
63
|
readonly ocspResponses?: readonly OcspResponseSource[];
|
|
50
64
|
/** Extra certs for indirect CRL issuers / delegated OCSP responders. */
|
|
51
65
|
readonly extraCertificates?: readonly CertificateSource[];
|
|
66
|
+
/**
|
|
67
|
+
* Explicitly trusted OCSP responder certificates (RFC 6960 §4.2.2.2
|
|
68
|
+
* criterion 1). A response signed by one of these is accepted without
|
|
69
|
+
* delegated-responder issuance, EKU, and revocation checks.
|
|
70
|
+
*/
|
|
71
|
+
readonly trustedOcspResponders?: readonly CertificateSource[];
|
|
52
72
|
/** Evaluation time. Defaults to `new Date()`. */
|
|
53
73
|
readonly at?: Date;
|
|
54
74
|
/** Revocation policy. */
|
|
@@ -81,6 +101,12 @@ interface RevocationSource {
|
|
|
81
101
|
readonly signerCertificate?: ParsedCertificate;
|
|
82
102
|
/** Identifier for debugging (e.g., CRL issuer DN or OCSP responder URL). */
|
|
83
103
|
readonly evidenceIdentifier?: string;
|
|
104
|
+
/**
|
|
105
|
+
* `thisUpdate` of the evidence backing the verdict — the OCSP single
|
|
106
|
+
* response entry or the freshest contributing CRL (an applied delta CRL
|
|
107
|
+
* supersedes its base). This is the timestamp `'best-available'` compares.
|
|
108
|
+
*/
|
|
109
|
+
readonly thisUpdate?: Date;
|
|
84
110
|
}
|
|
85
111
|
/**
|
|
86
112
|
* Revocation evaluation result for a single certificate.
|
|
@@ -167,6 +193,7 @@ type CheckChainRevocationResult = {
|
|
|
167
193
|
* const result = await checkChainRevocation({
|
|
168
194
|
* chain: validatedChain,
|
|
169
195
|
* crls: [crl1, crl2],
|
|
196
|
+
* ocspResponses: [ocspResponseDer],
|
|
170
197
|
* policy: { mode: 'hard-fail' },
|
|
171
198
|
* });
|
|
172
199
|
* if (result.value.decision === 'deny') {
|
package/dist/revocation/chain.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{parseCertificateFromSource as e}from"../x509/parse.js";import{checkCertificateRevocationAgainstCrl as t,parseCertificateRevocationListDer as n,parseCertificateRevocationListPem as r}from"./crl.js";function
|
|
1
|
+
import{parseCertificateFromSource as e}from"../x509/parse.js";import{checkCertificateRevocationAgainstCrl as t,parseCertificateRevocationListDer as n,parseCertificateRevocationListPem as r,revocationReasonFromCode as i}from"./crl.js";import{parseOcspResponseDer as a,parseOcspResponsePem as o,validateOcspResponse as s}from"./ocsp.js";function c(e){return typeof e==`object`&&`issuer`in e?e:typeof e==`string`?r(e):n(e)}function l(t){try{return e(t)}catch{return}}function u(e,t){if(e.der.length!==t.der.length)return!1;for(let n=0;n<e.der.length;n++)if(e.der[n]!==t.der[n])return!1;return!0}function d(e,t,n){let r=[];for(let e of t){let t=l(e);t!==void 0&&r.push(t)}let i=[...r,...n];if(e.authorityKeyIdentifier!==void 0){for(let t of i)if(t.subjectKeyIdentifier!==void 0&&f(e.authorityKeyIdentifier)===f(t.subjectKeyIdentifier))return t}for(let t of i)if(e.issuer.derHex===t.subject.derHex)return t}function f(e){return e.toLowerCase()}function p(e){return`${e.issuer.derHex}:${e.serialNumberHex}`}async function m(e,t){let n=p(e),r=t.cache.get(n);if(r===`visiting`)return`resolved-indeterminate`;if(r!==void 0)return r;t.cache.set(n,`visiting`);let i=t.chain[t.chain.length-1];if(i!==void 0&&u(e,i)||t.chain.some(t=>u(t,e)))return t.cache.set(n,`resolved-valid`),`resolved-valid`;let a=h(e,t);if(a===void 0)return t.cache.set(n,`resolved-indeterminate`),`resolved-indeterminate`;let o=await g(e,a,t);return t.cache.set(n,o),o}function h(e,t){let n=[];for(let e of t.extraCertificates){let t=l(e);t!==void 0&&n.push(t)}let r=[...t.chain,...n];for(let t of r)if(e.authorityKeyIdentifier!==void 0&&t.subjectKeyIdentifier!==void 0&&f(e.authorityKeyIdentifier)===f(t.subjectKeyIdentifier)||e.issuer.derHex===t.subject.derHex)return t}async function g(e,n,r){let i=r.chain.some(e=>u(e,n));for(let i of r.crls){let a;try{a=c(i)}catch{continue}let o=await t({certificate:e,issuerCertificate:n,crl:a,at:r.at});if(o.ok){if(o.value.status===`revoked`)return`resolved-revoked`;if(o.value.status===`good`&&await m(n,r)===`resolved-valid`)return`resolved-valid`}}return i?`resolved-valid`:`resolved-indeterminate`}function _(e,t,n,r,i,a){return n===`revoked`&&i!==void 0?{certificate:e,status:`revoked`,source:{type:`crl`,signerCertificate:t,thisUpdate:r},revocationInfo:{date:i,...a===void 0?{}:{reason:a}}}:{certificate:e,status:`good`,source:{type:`crl`,signerCertificate:t,thisUpdate:r}}}function v(e){return typeof e==`string`?o(e):a(e)}function y(e){switch(e){case`stale_response`:return`ocsp_response_expired`;case`responder_id_mismatch`:case`responder_chain_invalid`:case`ocsp_signing_missing`:return`ocsp_responder_not_authorized`;case`responder_revoked`:return`ocsp_responder_revoked`;case`signature_invalid`:case`responder_revocation_unknown`:return`ocsp_responder_indeterminate`;case`response_status_invalid`:case`issuer_mismatch`:case`nonce_mismatch`:case`request_mismatch`:return`no_applicable_ocsp`}}const b=new Set([`signature_invalid`,`responder_id_mismatch`,`responder_chain_invalid`,`ocsp_signing_missing`]);async function x(e,t,n,r){let i={issuerCertificate:t,at:r,...n.trustedOcspResponders===void 0?{}:{trustedResponderCertificates:n.trustedOcspResponders},...n.policy?.ocspResponderRevocation===void 0?{}:{responderRevocationPolicy:n.policy.ocspResponderRevocation},...n.crls===void 0?{}:{responderRevocationCrls:n.crls}},a=await s({response:e,...i});if(a.ok||!b.has(a.code))return a;for(let t of n.extraCertificates??[]){let n=l(t);if(n===void 0)continue;let r=await s({response:e,...i,responderCertificate:n});if(r.ok)return r}return a}async function S(e,t,n){let{ocspResponses:r=[],at:a=new Date}=n,o=[],s=new Set;for(let c of r){let r;try{r=v(c)}catch(e){o.push({kind:`parse_error`,message:e instanceof Error?e.message:`OCSP response parse failed`});continue}let l=(r.responses??[]).find(t=>f(t.certId.serialNumberHex)===f(e.serialNumberHex));if(l===void 0)continue;let u=await x(r,t,n,a);if(!u.ok){s.add(y(u.code));continue}if(l.certStatus===`revoked`){let t=i(l.revocationReasonCode);return{status:{certificate:e,status:`revoked`,source:{type:`ocsp`,thisUpdate:l.thisUpdate},revocationInfo:{date:l.revokedAt??l.thisUpdate,...t===void 0?{}:{reason:t}}},executionErrors:o}}if(l.certStatus===`good`)return{status:{certificate:e,status:`good`,source:{type:`ocsp`,thisUpdate:l.thisUpdate}},executionErrors:o};s.add(`ocsp_status_unknown`)}return s.size===0&&s.add(`no_applicable_ocsp`),{status:{certificate:e,status:`indeterminate`,indeterminateReasons:[...s]},executionErrors:o}}const C=[`keyCompromise`,`cACompromise`,`affiliationChanged`,`superseded`,`cessationOfOperation`,`certificateHold`,`privilegeWithdrawn`,`aACompromise`];async function w(e,n,r,i){let{crls:a=[],extraCertificates:o=[],chain:s=[],at:l=new Date}=r,f=[],p=!1,h=!1,g=!1,v,y=new Set,b=[];for(let e of a)try{b.push(c(e))}catch(e){f.push({kind:`parse_error`,message:e instanceof Error?e.message:`CRL parse failed`})}let x=b.filter(e=>e.baseCrlNumber===void 0),S=b.filter(e=>e.baseCrlNumber!==void 0),w=async(n,r,i)=>t({certificate:e,issuerCertificate:i,crl:n,...r===void 0?{}:{deltaCrl:r},at:l});for(let t of x){let r=S.find(e=>e.issuer.derHex===t.issuer.derHex&&e.baseCrlNumber!==void 0&&t.crlNumber!==void 0&&BigInt(e.baseCrlNumber)<=BigInt(t.crlNumber)),a=await w(t,r,n),c=n;if(!a.ok){let e=d(t,o,s);e!==void 0&&!u(e,n)&&(a=await w(t,r,e),c=e)}if(!a.ok)continue;let l=await m(c,i);if(l===`resolved-revoked`){p=!0;continue}if(l===`resolved-indeterminate`){h=!0;continue}let b=r!==void 0&&r.thisUpdate.getTime()>t.thisUpdate.getTime()?r.thisUpdate:t.thisUpdate;if(a.value.status===`revoked`)return{status:_(e,c,`revoked`,b,a.value.revocationDate,a.value.reasonCode),executionErrors:f};g=!0,(v===void 0||b.getTime()>v.thisUpdate.getTime())&&(v={signer:c,thisUpdate:b});let x=t.issuingDistributionPoint?.onlySomeReasons?.flags;if(x===void 0)for(let e of C)y.add(e);else for(let e of x)y.add(e)}if(g)return C.every(e=>y.has(e))?{status:{certificate:e,status:`good`,...v===void 0?{}:{source:{type:`crl`,signerCertificate:v.signer,thisUpdate:v.thisUpdate}}},executionErrors:f}:{status:{certificate:e,status:`indeterminate`,indeterminateReasons:[`reason_coverage_incomplete`]},executionErrors:f};let T=[];return p?T.push(`crl_signer_revoked`):h?T.push(`crl_signer_indeterminate`):T.push(`no_applicable_crl`),{status:{certificate:e,status:`indeterminate`,indeterminateReasons:T},executionErrors:f}}async function T(e,t,n,r){let i=n.policy?.prefer??`best-available`,a=await S(e,t,n),o=await w(e,t,n,r),s=[...a.executionErrors,...o.executionErrors],c=i===`crl`?[o,a]:i===`ocsp`?[a,o]:[a,o].sort((e,t)=>(t.status.source?.thisUpdate?.getTime()??0)-(e.status.source?.thisUpdate?.getTime()??0)),l=c.find(e=>e.status.status===`revoked`);if(l!==void 0)return{status:l.status,executionErrors:s};let u=c.find(e=>e.status.status===`good`);if(u!==void 0)return{status:u.status,executionErrors:s};let d=new Set;for(let e of c)for(let t of e.status.indeterminateReasons??[])d.add(t);return{status:{certificate:e,status:`indeterminate`,indeterminateReasons:[...d]},executionErrors:s}}async function E(e){let{chain:t,policy:n,crls:r=[],extraCertificates:i=[],at:a=new Date}=e,o=n?.mode??`soft-fail`;if(t.length===0)return{ok:!0,value:{decision:`allow`,summary:{revokedCertificates:[],indeterminateCertificates:[]},certificates:[]}};let s={cache:new Map,chain:t,crls:r,extraCertificates:i,at:a},c=t.slice(0,-1),l=[],u=[],d=[],f=[];for(let n=0;n<c.length;n++){let r=c[n],i=t[n+1];if(r===void 0||i===void 0)continue;let{status:a,executionErrors:o}=await T(r,i,e,s);l.push(a),f.push(...o),a.status===`revoked`?u.push(r):a.status===`indeterminate`&&d.push(r)}let p=u.length>0,m=d.length>0;return{ok:!0,value:{decision:p||m&&o===`hard-fail`?`deny`:`allow`,summary:{revokedCertificates:u,indeterminateCertificates:d},certificates:l,...f.length>0?{executionErrors:f}:{}}}}export{E as checkChainRevocation};
|
|
2
2
|
//# sourceMappingURL=chain.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.js","names":[],"sources":["../../src/revocation/chain.ts"],"sourcesContent":["/**\n * Chain-level revocation orchestration.\n *\n * Evaluates CRL and OCSP evidence for an entire validated certificate chain,\n * implementing the revocation checking portion of RFC 5280 §6.3.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-6.3 | RFC 5280 §6.3 CRL Validation}\n * @module\n */\n\nimport type { ParsedCertificate } from '#micro509/x509/parse.ts';\nimport { parseCertificateFromSource } from '#micro509/x509/parse.ts';\nimport {\n\tcheckCertificateRevocationAgainstCrl,\n\tparseCertificateRevocationListDer,\n\tparseCertificateRevocationListPem,\n\ttype ParsedCertificateRevocationList,\n\ttype RevocationReason,\n} from './crl.ts';\nimport type { CrlSource } from './crl.ts';\n\nexport type { CrlSource };\n\n// ---------------------------------------------------------------------------\n// Input Types\n// ---------------------------------------------------------------------------\n\n/**\n * Certificate in any supported format.\n *\n * Accepts PEM string, DER bytes, or an already-parsed {@linkcode ParsedCertificate}.\n * Used for {@linkcode CheckChainRevocationInput.extraCertificates}.\n */\nexport type CertificateSource = string | Uint8Array | ParsedCertificate;\n\n/**\n * OCSP response in any supported format.\n *\n * Accepts PEM string or DER bytes. Reserved for future OCSP support in\n * {@linkcode CheckChainRevocationInput.ocspResponses}.\n */\nexport type OcspResponseSource = string | Uint8Array;\n\n/**\n * Revocation checking policy for {@linkcode checkChainRevocation}.\n *\n * Controls how indeterminate results (missing evidence, expired CRLs) affect\n * the final {@linkcode CheckChainRevocationValue.decision | decision}.\n */\nexport interface RevocationPolicy {\n\t/**\n\t * How to handle indeterminate status.\n\t *\n\t * - `'soft-fail'`: indeterminate certificates are allowed (default)\n\t * - `'hard-fail'`: indeterminate certificates cause denial\n\t */\n\treadonly mode?: 'soft-fail' | 'hard-fail';\n\t/**\n\t * Evidence preference when multiple sources are available.\n\t *\n\t * - `'best-available'`: use whichever evidence is freshest (default)\n\t * - `'ocsp'`: prefer OCSP over CRL\n\t * - `'crl'`: prefer CRL over OCSP\n\t */\n\treadonly prefer?: 'ocsp' | 'crl' | 'best-available';\n}\n\n/** Input for {@linkcode checkChainRevocation}. */\nexport interface CheckChainRevocationInput {\n\t/** Validated certificate chain (leaf first, root last). */\n\treadonly chain: readonly ParsedCertificate[];\n\t/** CRLs to evaluate. */\n\treadonly crls?: readonly CrlSource[];\n\t/** OCSP responses to evaluate. */\n\treadonly ocspResponses?: readonly OcspResponseSource[];\n\t/** Extra certs for indirect CRL issuers / delegated OCSP responders. */\n\treadonly extraCertificates?: readonly CertificateSource[];\n\t/** Evaluation time. Defaults to `new Date()`. */\n\treadonly at?: Date;\n\t/** Revocation policy. */\n\treadonly policy?: RevocationPolicy;\n}\n\n// ---------------------------------------------------------------------------\n// Output Types\n// ---------------------------------------------------------------------------\n\n/**\n * Granular reasons why revocation status could not be determined.\n *\n * Returned in {@linkcode CertificateRevocationStatus.indeterminateReasons} when\n * `status` is `'indeterminate'`. Grouped by category:\n *\n * - **Evidence not found**: `no_applicable_crl`, `no_applicable_ocsp`\n * - **Scope mismatch**: `distribution_point_mismatch`, `issuer_name_mismatch`,\n * `reason_scope_mismatch`, `indirect_crl_scope_mismatch`, `reason_coverage_incomplete`\n * - **Signer trust**: `crl_signer_not_found`, `crl_signer_not_authorized`,\n * `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents\n * - **Freshness**: `crl_expired`, `ocsp_response_expired`\n */\nexport type RevocationIndeterminateReason =\n\t// Evidence not found\n\t| 'no_applicable_crl'\n\t| 'no_applicable_ocsp'\n\t// Scope issues\n\t| 'distribution_point_mismatch'\n\t| 'issuer_name_mismatch'\n\t| 'reason_scope_mismatch'\n\t| 'indirect_crl_scope_mismatch'\n\t| 'reason_coverage_incomplete'\n\t// Signer trust issues\n\t| 'crl_signer_not_found'\n\t| 'crl_signer_not_authorized'\n\t| 'crl_signer_revoked'\n\t| 'crl_signer_indeterminate'\n\t| 'ocsp_responder_not_found'\n\t| 'ocsp_responder_not_authorized'\n\t| 'ocsp_responder_revoked'\n\t| 'ocsp_responder_indeterminate'\n\t// Freshness\n\t| 'crl_expired'\n\t| 'ocsp_response_expired'\n\t// OCSP specific\n\t| 'ocsp_status_unknown';\n\n/**\n * Identifies the source of revocation evidence.\n *\n * Included in {@linkcode CertificateRevocationStatus.source} when status is\n * `'good'` or `'revoked'` to indicate which CRL or OCSP response provided the answer.\n */\nexport interface RevocationSource {\n\t/** Whether evidence came from a CRL or OCSP response. */\n\treadonly type: 'crl' | 'ocsp';\n\t/** Certificate that signed the evidence (CRL issuer or OCSP responder). */\n\treadonly signerCertificate?: ParsedCertificate;\n\t/** Identifier for debugging (e.g., CRL issuer DN or OCSP responder URL). */\n\treadonly evidenceIdentifier?: string;\n}\n\n/**\n * Revocation evaluation result for a single certificate.\n *\n * One entry per certificate in {@linkcode CheckChainRevocationValue.certificates}.\n * The trust anchor is excluded (never checked for revocation).\n */\nexport interface CertificateRevocationStatus {\n\t/** The certificate that was evaluated. */\n\treadonly certificate: ParsedCertificate;\n\t/**\n\t * Revocation status determination.\n\t *\n\t * - `'good'`: evidence confirms certificate is not revoked\n\t * - `'revoked'`: evidence confirms certificate is revoked\n\t * - `'indeterminate'`: could not determine status (see {@linkcode indeterminateReasons})\n\t */\n\treadonly status: 'good' | 'revoked' | 'indeterminate';\n\t/** Evidence source when status is `'good'` or `'revoked'`. */\n\treadonly source?: RevocationSource;\n\t/** Why status could not be determined. Present when `status` is `'indeterminate'`. */\n\treadonly indeterminateReasons?: readonly RevocationIndeterminateReason[];\n\t/** Revocation details. Present when `status` is `'revoked'`. */\n\treadonly revocationInfo?: {\n\t\t/** When the certificate was revoked. */\n\t\treadonly date: Date;\n\t\t/** RFC 5280 CRLReason code, if provided by the CRL/OCSP response. */\n\t\treadonly reason?: RevocationReason;\n\t};\n}\n\n/**\n * Errors encountered while processing revocation evidence.\n *\n * Distinct from {@linkcode RevocationIndeterminateReason}: execution errors are\n * code failures (malformed CRL, unsupported extension) rather than evaluation\n * outcomes (CRL doesn't cover this certificate).\n *\n * Collected in {@linkcode CheckChainRevocationValue.executionErrors}.\n */\nexport interface RevocationExecutionError {\n\t/** Error category. */\n\treadonly kind: 'parse_error' | 'unsupported_extension' | 'internal_error';\n\t/** Human-readable error description. */\n\treadonly message: string;\n\t/** Which evidence caused the error (e.g., CRL issuer DN). */\n\treadonly evidenceIdentifier?: string;\n}\n\n/**\n * Detailed revocation check results.\n *\n * Returned as {@linkcode CheckChainRevocationResult.value} from\n * {@linkcode checkChainRevocation}. Contains both the policy decision and\n * detailed per-certificate findings for debugging.\n */\nexport interface CheckChainRevocationValue {\n\t/**\n\t * Final policy decision based on {@linkcode RevocationPolicy}.\n\t *\n\t * - `'allow'`: chain passes revocation check\n\t * - `'deny'`: chain fails (revoked certificate or hard-fail on indeterminate)\n\t */\n\treadonly decision: 'allow' | 'deny';\n\t/** Quick-access summary of problematic certificates. */\n\treadonly summary: {\n\t\t/** Certificates confirmed as revoked. */\n\t\treadonly revokedCertificates: readonly ParsedCertificate[];\n\t\t/** Certificates whose status could not be determined. */\n\t\treadonly indeterminateCertificates: readonly ParsedCertificate[];\n\t};\n\t/** Per-certificate evaluation results. See {@linkcode CertificateRevocationStatus}. */\n\treadonly certificates: readonly CertificateRevocationStatus[];\n\t/** Evidence that could not be processed. See {@linkcode RevocationExecutionError}. */\n\treadonly executionErrors?: readonly RevocationExecutionError[];\n}\n\n/** Result type for {@linkcode checkChainRevocation}. */\nexport type CheckChainRevocationResult = {\n\treadonly ok: true;\n\treadonly value: CheckChainRevocationValue;\n};\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Parses a CRL from various source formats.\n */\nfunction parseCrlFromSource(source: CrlSource): ParsedCertificateRevocationList {\n\tif (typeof source === 'object' && 'issuer' in source) {\n\t\treturn source;\n\t}\n\tif (typeof source === 'string') {\n\t\treturn parseCertificateRevocationListPem(source);\n\t}\n\treturn parseCertificateRevocationListDer(source);\n}\n\n/**\n * Parses a certificate from various source formats, returning undefined on failure.\n */\nfunction parseCertificateSafe(source: CertificateSource): ParsedCertificate | undefined {\n\ttry {\n\t\treturn parseCertificateFromSource(source);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Compares two certificates by DER bytes for identity.\n * Reference equality fails when same cert is parsed from different sources.\n */\nfunction sameCertificate(a: ParsedCertificate, b: ParsedCertificate): boolean {\n\tif (a.der.length !== b.der.length) return false;\n\tfor (let i = 0; i < a.der.length; i++) {\n\t\tif (a.der[i] !== b.der[i]) return false;\n\t}\n\treturn true;\n}\n\n/**\n * Searches for a certificate that could have signed the given CRL.\n * Matches by AKI/SKI or issuer/subject DN.\n */\nfunction findIndirectCrlIssuer(\n\tcrl: ParsedCertificateRevocationList,\n\textraCertificates: readonly CertificateSource[],\n\tchain: readonly ParsedCertificate[],\n): ParsedCertificate | undefined {\n\t// Combine extra certs with chain certs for searching\n\t// Chain certs are already parsed; extra certs may need parsing\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...parsedExtras, ...chain];\n\n\t// First pass: prefer AKI/SKI match (more specific)\n\tif (crl.authorityKeyIdentifier !== undefined) {\n\t\tfor (const candidate of candidates) {\n\t\t\tif (\n\t\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\t\tnormalizeHex(crl.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t\t) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Second pass: fall back to DN match\n\tfor (const candidate of candidates) {\n\t\tif (crl.issuer.derHex === candidate.subject.derHex) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/** Lowercases a hex string for bytewise comparison. */\nfunction normalizeHex(value: string): string {\n\treturn value.toLowerCase();\n}\n\n// ---------------------------------------------------------------------------\n// CRL Signer Validation (RFC 5280 §6.3.3)\n// ---------------------------------------------------------------------------\n\n/**\n * State machine for CRL signer validation with memoization.\n * - `visiting`: Currently being checked (cycle detection)\n * - `resolved-valid`: Signer is not revoked\n * - `resolved-revoked`: Signer is revoked\n * - `resolved-indeterminate`: Can't determine signer status\n */\ntype SignerValidationState =\n\t| 'visiting'\n\t| 'resolved-valid'\n\t| 'resolved-revoked'\n\t| 'resolved-indeterminate';\n\n/** Context for CRL signer validation with memoization cache. */\ninterface SignerValidationContext {\n\treadonly cache: Map<string, SignerValidationState>;\n\treadonly chain: readonly ParsedCertificate[];\n\treadonly crls: readonly CrlSource[];\n\treadonly extraCertificates: readonly CertificateSource[];\n\treadonly at: Date;\n}\n\n/**\n * Builds a unique cache key for a certificate.\n * Uses issuer DN + serial number which uniquely identifies a cert.\n */\nfunction certCacheKey(cert: ParsedCertificate): string {\n\treturn `${cert.issuer.derHex}:${cert.serialNumberHex}`;\n}\n\n/**\n * Validates that a CRL signer certificate is not revoked.\n * Uses memoization to avoid redundant checks and detect cycles.\n */\nasync function validateCrlSigner(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// Use issuer+serial as cache key (unique per certificate)\n\tconst key = certCacheKey(signer);\n\tconst cached = ctx.cache.get(key);\n\n\t// Cycle detection: if we're already visiting this signer, it's indeterminate\n\tif (cached === 'visiting') {\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Return cached result if already resolved\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\t// Mark as visiting before recursive checks\n\tctx.cache.set(key, 'visiting');\n\n\t// Trust anchor (last in chain) is trusted by definition\n\tconst trustAnchor = ctx.chain[ctx.chain.length - 1];\n\tif (trustAnchor !== undefined && sameCertificate(signer, trustAnchor)) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// If signer is in the validated chain, it's trusted\n\t// (Chain was already validated before revocation checking)\n\tconst isInChain = ctx.chain.some((c) => sameCertificate(c, signer));\n\tif (isInChain) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// Signer is not in chain — need to check its revocation status\n\t// Find signer's issuer to perform revocation check\n\tconst signerIssuer = findSignerIssuer(signer, ctx);\n\tif (signerIssuer === undefined) {\n\t\tctx.cache.set(key, 'resolved-indeterminate');\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Check signer's revocation status (recursive)\n\tconst signerRevocation = await checkSignerRevocation(signer, signerIssuer, ctx);\n\tctx.cache.set(key, signerRevocation);\n\treturn signerRevocation;\n}\n\n/**\n * Finds the issuer certificate for a CRL signer.\n * Searches the chain and extraCertificates by AKI/SKI or DN matching.\n */\nfunction findSignerIssuer(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): ParsedCertificate | undefined {\n\t// Parse extra certificates\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of ctx.extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...ctx.chain, ...parsedExtras];\n\n\tfor (const candidate of candidates) {\n\t\t// Match by AKI → SKI (preferred, more specific)\n\t\tif (\n\t\t\tsigner.authorityKeyIdentifier !== undefined &&\n\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\tnormalizeHex(signer.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t) {\n\t\t\treturn candidate;\n\t\t}\n\n\t\t// Match by issuer DN → subject DN\n\t\tif (signer.issuer.derHex === candidate.subject.derHex) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks if a CRL signer certificate is revoked by examining available CRLs.\n * Recursively validates the CRL signer of any CRL used to check revocation.\n */\nasync function checkSignerRevocation(\n\tsigner: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// If the signer's issuer is in the validated chain, the signer is trusted\n\t// by virtue of being issued by a trusted CA. We only need to check if\n\t// it's explicitly revoked, not prove \"good\" status.\n\tconst issuerInChain = ctx.chain.some((c) => sameCertificate(c, issuer));\n\n\t// Try each CRL to check signer's revocation\n\tfor (const crlSource of ctx.crls) {\n\t\tlet crl: ParsedCertificateRevocationList;\n\t\ttry {\n\t\t\tcrl = parseCrlFromSource(crlSource);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if this CRL can provide revocation info for the signer\n\t\tconst result = await checkCertificateRevocationAgainstCrl({\n\t\t\tcertificate: signer,\n\t\t\tissuerCertificate: issuer,\n\t\t\tcrl,\n\t\t\tat: ctx.at,\n\t\t});\n\n\t\tif (result.ok) {\n\t\t\tif (result.value.status === 'revoked') {\n\t\t\t\treturn 'resolved-revoked';\n\t\t\t}\n\t\t\tif (result.value.status === 'good') {\n\t\t\t\t// Before accepting this result, validate the CRL's signer\n\t\t\t\t// The CRL's signer is the issuer we just used\n\t\t\t\tconst crlSignerStatus = await validateCrlSigner(issuer, ctx);\n\t\t\t\tif (crlSignerStatus === 'resolved-valid') {\n\t\t\t\t\treturn 'resolved-valid';\n\t\t\t\t}\n\t\t\t\t// If CRL signer is revoked or indeterminate, can't trust this result\n\t\t\t}\n\t\t}\n\t}\n\n\t// If the signer's issuer is in the chain and we found no revocation,\n\t// trust the signer (issued by trusted CA, no evidence of revocation)\n\tif (issuerInChain) {\n\t\treturn 'resolved-valid';\n\t}\n\n\treturn 'resolved-indeterminate';\n}\n\n/** Builds a CertificateRevocationStatus for a CRL check result. */\nfunction buildCrlStatus(\n\tcert: ParsedCertificate,\n\tsigner: ParsedCertificate,\n\tstatus: 'good' | 'revoked',\n\trevocationDate?: Date,\n\treasonCode?: RevocationReason,\n): CertificateRevocationStatus {\n\tif (status === 'revoked' && revocationDate !== undefined) {\n\t\treturn {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'revoked',\n\t\t\tsource: { type: 'crl', signerCertificate: signer },\n\t\t\trevocationInfo: {\n\t\t\t\tdate: revocationDate,\n\t\t\t\t...(reasonCode !== undefined ? { reason: reasonCode } : {}),\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\tcertificate: cert,\n\t\tstatus: 'good',\n\t\tsource: { type: 'crl', signerCertificate: signer },\n\t};\n}\n\n/**\n * Evaluates revocation status for a single certificate using available CRLs.\n * Returns both status and any execution errors encountered.\n *\n * Tries the chain issuer first; if that fails, searches extraCertificates\n * and chain for an indirect CRL issuer that matches the CRL's AKI or issuer DN.\n *\n * Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).\n */\n// RFC 5280 ReasonFlags — all possible revocation reasons that CRLs can cover.\nconst ALL_REASON_FLAGS: readonly string[] = [\n\t'keyCompromise',\n\t'cACompromise',\n\t'affiliationChanged',\n\t'superseded',\n\t'cessationOfOperation',\n\t'certificateHold',\n\t'privilegeWithdrawn',\n\t'aACompromise',\n];\n\nasync function evaluateCertificateRevocation(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<{\n\tstatus: CertificateRevocationStatus;\n\texecutionErrors: readonly RevocationExecutionError[];\n}> {\n\tconst { crls = [], extraCertificates = [], chain = [], at = new Date() } = input;\n\tconst executionErrors: RevocationExecutionError[] = [];\n\tlet sawCrlSignerRevoked = false;\n\tlet sawCrlSignerIndeterminate = false;\n\tlet sawGood = false;\n\tlet lastGoodSigner: ParsedCertificate | undefined;\n\tconst coveredReasons = new Set<string>();\n\n\t// Parse all CRLs and separate base CRLs from delta CRLs\n\tconst parsedCrls: ParsedCertificateRevocationList[] = [];\n\tfor (const crlSource of crls) {\n\t\ttry {\n\t\t\tparsedCrls.push(parseCrlFromSource(crlSource));\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'CRL parse failed',\n\t\t\t});\n\t\t}\n\t}\n\n\tconst baseCrls = parsedCrls.filter((crl) => crl.baseCrlNumber === undefined);\n\tconst deltaCrls = parsedCrls.filter((crl) => crl.baseCrlNumber !== undefined);\n\n\t// Helper to check CRL with given issuer and optional delta\n\tconst checkWithIssuer = async (\n\t\tcrl: ParsedCertificateRevocationList,\n\t\tdeltaCrl: ParsedCertificateRevocationList | undefined,\n\t\tcrlIssuer: ParsedCertificate,\n\t) => {\n\t\treturn checkCertificateRevocationAgainstCrl({\n\t\t\tcertificate: cert,\n\t\t\tissuerCertificate: crlIssuer,\n\t\t\tcrl,\n\t\t\t...(deltaCrl !== undefined ? { deltaCrl } : {}),\n\t\t\tat,\n\t\t});\n\t};\n\n\t// Process base CRLs (optionally paired with delta CRLs)\n\tfor (const baseCrl of baseCrls) {\n\t\t// Find applicable delta CRL for this base CRL (if any)\n\t\t// Delta CRL applies if it has the same issuer and crlNumber matches baseCrlNumber\n\t\tconst applicableDelta = deltaCrls.find(\n\t\t\t(d) =>\n\t\t\t\td.issuer.derHex === baseCrl.issuer.derHex &&\n\t\t\t\td.baseCrlNumber !== undefined &&\n\t\t\t\tbaseCrl.crlNumber !== undefined &&\n\t\t\t\tBigInt(d.baseCrlNumber) <= BigInt(baseCrl.crlNumber),\n\t\t);\n\n\t\t// Try chain issuer first\n\t\tlet result = await checkWithIssuer(baseCrl, applicableDelta, issuer);\n\t\tlet effectiveSigner = issuer;\n\n\t\t// Chain issuer failed — try to find indirect CRL issuer\n\t\tif (!result.ok) {\n\t\t\tconst indirectIssuer = findIndirectCrlIssuer(baseCrl, extraCertificates, chain);\n\t\t\tif (indirectIssuer !== undefined && !sameCertificate(indirectIssuer, issuer)) {\n\t\t\t\tresult = await checkWithIssuer(baseCrl, applicableDelta, indirectIssuer);\n\t\t\t\teffectiveSigner = indirectIssuer;\n\t\t\t}\n\t\t}\n\n\t\tif (!result.ok) {\n\t\t\tcontinue; // CRL doesn't apply to this certificate\n\t\t}\n\n\t\t// Validate CRL signer is not revoked before accepting result\n\t\tconst signerStatus = await validateCrlSigner(effectiveSigner, signerCtx);\n\t\tif (signerStatus === 'resolved-revoked') {\n\t\t\tsawCrlSignerRevoked = true;\n\t\t\tcontinue; // CRL signer revoked — can't trust this CRL\n\t\t}\n\t\tif (signerStatus === 'resolved-indeterminate') {\n\t\t\tsawCrlSignerIndeterminate = true;\n\t\t\tcontinue; // CRL signer status unknown — try other CRLs\n\t\t}\n\n\t\t// CRL is valid — check result\n\t\tif (result.value.status === 'revoked') {\n\t\t\t// Immediately return revoked status\n\t\t\treturn {\n\t\t\t\tstatus: buildCrlStatus(\n\t\t\t\t\tcert,\n\t\t\t\t\teffectiveSigner,\n\t\t\t\t\t'revoked',\n\t\t\t\t\tresult.value.revocationDate,\n\t\t\t\t\tresult.value.reasonCode,\n\t\t\t\t),\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\n\t\t// Status is 'good' — track which reasons this CRL covers\n\t\tsawGood = true;\n\t\tlastGoodSigner = effectiveSigner;\n\t\tconst crlReasons = baseCrl.issuingDistributionPoint?.onlySomeReasons?.flags;\n\t\tif (crlReasons === undefined) {\n\t\t\t// CRL covers all reasons\n\t\t\tfor (const reason of ALL_REASON_FLAGS) {\n\t\t\t\tcoveredReasons.add(reason);\n\t\t\t}\n\t\t} else {\n\t\t\t// CRL only covers specific reasons\n\t\t\tfor (const reason of crlReasons) {\n\t\t\t\tcoveredReasons.add(reason);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return 'good' only if we saw at least one good result AND all reasons are covered\n\tif (sawGood) {\n\t\tconst allReasonsCovered = ALL_REASON_FLAGS.every((r) => coveredReasons.has(r));\n\t\tif (allReasonsCovered) {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\t...(lastGoodSigner !== undefined\n\t\t\t\t\t\t? { source: { type: 'crl', signerCertificate: lastGoodSigner } }\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\t// Not all reasons covered — indeterminate\n\t\treturn {\n\t\t\tstatus: {\n\t\t\t\tcertificate: cert,\n\t\t\t\tstatus: 'indeterminate',\n\t\t\t\tindeterminateReasons: ['reason_coverage_incomplete'],\n\t\t\t},\n\t\t\texecutionErrors,\n\t\t};\n\t}\n\n\t// No applicable CRL found — determine most appropriate indeterminate reason\n\tconst reasons: RevocationIndeterminateReason[] = [];\n\tif (sawCrlSignerRevoked) {\n\t\treasons.push('crl_signer_revoked');\n\t} else if (sawCrlSignerIndeterminate) {\n\t\treasons.push('crl_signer_indeterminate');\n\t} else if (crls.length === 0) {\n\t\treasons.push('no_applicable_crl', 'no_applicable_ocsp');\n\t} else {\n\t\treasons.push('no_applicable_crl');\n\t}\n\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: reasons,\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Function\n// ---------------------------------------------------------------------------\n\n/**\n * Checks revocation status for all certificates in a validated chain.\n *\n * Evaluates CRL and OCSP evidence against each certificate (except the trust\n * anchor), applies the revocation policy, and returns a unified decision.\n *\n * @example\n * ```ts\n * const result = await checkChainRevocation({\n * chain: validatedChain,\n * crls: [crl1, crl2],\n * policy: { mode: 'hard-fail' },\n * });\n * if (result.value.decision === 'deny') {\n * console.log('Revocation check failed');\n * }\n * ```\n */\nexport async function checkChainRevocation(\n\tinput: CheckChainRevocationInput,\n): Promise<CheckChainRevocationResult> {\n\tconst { chain, policy, crls = [], extraCertificates = [], at = new Date() } = input;\n\tconst mode = policy?.mode ?? 'soft-fail';\n\n\t// Empty chain → allow\n\tif (chain.length === 0) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tdecision: 'allow',\n\t\t\t\tsummary: { revokedCertificates: [], indeterminateCertificates: [] },\n\t\t\t\tcertificates: [],\n\t\t\t},\n\t\t};\n\t}\n\n\t// Create signer validation context with memoization cache\n\t// This cache is shared across all certificate checks in this chain evaluation\n\tconst signerCtx: SignerValidationContext = {\n\t\tcache: new Map(),\n\t\tchain,\n\t\tcrls,\n\t\textraCertificates,\n\t\tat,\n\t};\n\n\t// Skip trust anchor (last cert) — it's the trust base\n\tconst certsToCheck = chain.slice(0, -1);\n\tconst certificates: CertificateRevocationStatus[] = [];\n\tconst revokedCertificates: ParsedCertificate[] = [];\n\tconst indeterminateCertificates: ParsedCertificate[] = [];\n\tconst allExecutionErrors: RevocationExecutionError[] = [];\n\n\tfor (let i = 0; i < certsToCheck.length; i++) {\n\t\tconst cert = certsToCheck[i];\n\t\tconst issuer = chain[i + 1]; // Next cert in chain is the issuer\n\t\tif (cert === undefined || issuer === undefined) {\n\t\t\tcontinue; // Should never happen given loop bounds\n\t\t}\n\n\t\tconst { status, executionErrors } = await evaluateCertificateRevocation(\n\t\t\tcert,\n\t\t\tissuer,\n\t\t\tinput,\n\t\t\tsignerCtx,\n\t\t);\n\t\tcertificates.push(status);\n\t\tallExecutionErrors.push(...executionErrors);\n\n\t\tif (status.status === 'revoked') {\n\t\t\trevokedCertificates.push(cert);\n\t\t} else if (status.status === 'indeterminate') {\n\t\t\tindeterminateCertificates.push(cert);\n\t\t}\n\t}\n\n\t// Apply policy\n\tconst hasRevoked = revokedCertificates.length > 0;\n\tconst hasIndeterminate = indeterminateCertificates.length > 0;\n\tconst decision: 'allow' | 'deny' = hasRevoked\n\t\t? 'deny'\n\t\t: hasIndeterminate && mode === 'hard-fail'\n\t\t\t? 'deny'\n\t\t\t: 'allow';\n\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tdecision,\n\t\t\tsummary: { revokedCertificates, indeterminateCertificates },\n\t\t\tcertificates,\n\t\t\t...(allExecutionErrors.length > 0 ? { executionErrors: allExecutionErrors } : {}),\n\t\t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N,SATiC,GAEhC,GAAoB,IAAS,YAD7B,OAGC,QAMF,QAAS,CAAE,sBAAqB,2BAA0B,EAC1D,eACA,GAAI,EAAmB,OAAS,EAAI,CAAE,gBAAiB,CAAmB,EAAI,CAAC,CAChF,CACD,CACD"}
|
|
1
|
+
{"version":3,"file":"chain.js","names":[],"sources":["../../src/revocation/chain.ts"],"sourcesContent":["/**\n * Chain-level revocation orchestration.\n *\n * Evaluates CRL and OCSP evidence for an entire validated certificate chain,\n * implementing the revocation checking portion of RFC 5280 §6.3.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc5280#section-6.3 | RFC 5280 §6.3 CRL Validation}\n * @module\n */\n\nimport type { ParsedCertificate } from '#micro509/x509/parse.ts';\nimport { parseCertificateFromSource } from '#micro509/x509/parse.ts';\nimport {\n\tcheckCertificateRevocationAgainstCrl,\n\tparseCertificateRevocationListDer,\n\tparseCertificateRevocationListPem,\n\ttype ParsedCertificateRevocationList,\n\ttype RevocationReason,\n\trevocationReasonFromCode,\n} from './crl.ts';\nimport type { CrlSource } from './crl.ts';\nimport {\n\ttype OcspResponderRevocationPolicy,\n\ttype ParsedOcspResponse,\n\tparseOcspResponseDer,\n\tparseOcspResponsePem,\n\ttype ValidateOcspResponseFailure,\n\ttype ValidateOcspResponseResult,\n\tvalidateOcspResponse,\n} from './ocsp.ts';\n\nexport type { CrlSource };\n\n// ---------------------------------------------------------------------------\n// Input Types\n// ---------------------------------------------------------------------------\n\n/**\n * Certificate in any supported format.\n *\n * Accepts PEM string, DER bytes, or an already-parsed {@linkcode ParsedCertificate}.\n * Used for {@linkcode CheckChainRevocationInput.extraCertificates}.\n */\nexport type CertificateSource = string | Uint8Array | ParsedCertificate;\n\n/**\n * OCSP response in any supported format.\n *\n * Accepts PEM string or DER bytes. Used for\n * {@linkcode CheckChainRevocationInput.ocspResponses}.\n */\nexport type OcspResponseSource = string | Uint8Array;\n\n/**\n * Revocation checking policy for {@linkcode checkChainRevocation}.\n *\n * Controls how indeterminate results (missing evidence, expired CRLs) affect\n * the final {@linkcode CheckChainRevocationValue.decision | decision}.\n */\nexport interface RevocationPolicy {\n\t/**\n\t * How to handle indeterminate status.\n\t *\n\t * - `'soft-fail'`: indeterminate certificates are allowed (default)\n\t * - `'hard-fail'`: indeterminate certificates cause denial\n\t */\n\treadonly mode?: 'soft-fail' | 'hard-fail';\n\t/**\n\t * Evidence preference when multiple sources are available.\n\t *\n\t * Both evidence kinds are always evaluated, and a validated `revoked`\n\t * verdict from either source wins regardless of preference (fail-closed).\n\t * Preference only decides which source's `good` verdict is reported when\n\t * both yield one.\n\t *\n\t * - `'best-available'`: the source with the fresher evidence — the later\n\t * `thisUpdate` on the validated OCSP entry or CRL — is reported; ties\n\t * favor OCSP (default)\n\t * - `'ocsp'`: prefer OCSP over CRL\n\t * - `'crl'`: prefer CRL over OCSP\n\t */\n\treadonly prefer?: 'ocsp' | 'crl' | 'best-available';\n\t/**\n\t * Revocation policy for delegated OCSP responder certificates\n\t * (RFC 6960 §4.2.2.2.1). Supplied CRLs double as responder revocation\n\t * evidence. Defaults to `'honor-nocheck'`.\n\t */\n\treadonly ocspResponderRevocation?: OcspResponderRevocationPolicy;\n}\n\n/** Input for {@linkcode checkChainRevocation}. */\nexport interface CheckChainRevocationInput {\n\t/** Validated certificate chain (leaf first, root last). */\n\treadonly chain: readonly ParsedCertificate[];\n\t/** CRLs to evaluate. */\n\treadonly crls?: readonly CrlSource[];\n\t/** OCSP responses to evaluate. */\n\treadonly ocspResponses?: readonly OcspResponseSource[];\n\t/** Extra certs for indirect CRL issuers / delegated OCSP responders. */\n\treadonly extraCertificates?: readonly CertificateSource[];\n\t/**\n\t * Explicitly trusted OCSP responder certificates (RFC 6960 §4.2.2.2\n\t * criterion 1). A response signed by one of these is accepted without\n\t * delegated-responder issuance, EKU, and revocation checks.\n\t */\n\treadonly trustedOcspResponders?: readonly CertificateSource[];\n\t/** Evaluation time. Defaults to `new Date()`. */\n\treadonly at?: Date;\n\t/** Revocation policy. */\n\treadonly policy?: RevocationPolicy;\n}\n\n// ---------------------------------------------------------------------------\n// Output Types\n// ---------------------------------------------------------------------------\n\n/**\n * Granular reasons why revocation status could not be determined.\n *\n * Returned in {@linkcode CertificateRevocationStatus.indeterminateReasons} when\n * `status` is `'indeterminate'`. Grouped by category:\n *\n * - **Evidence not found**: `no_applicable_crl`, `no_applicable_ocsp`\n * - **Scope mismatch**: `distribution_point_mismatch`, `issuer_name_mismatch`,\n * `reason_scope_mismatch`, `indirect_crl_scope_mismatch`, `reason_coverage_incomplete`\n * - **Signer trust**: `crl_signer_not_found`, `crl_signer_not_authorized`,\n * `crl_signer_revoked`, `crl_signer_indeterminate`, and OCSP equivalents\n * - **Freshness**: `crl_expired`, `ocsp_response_expired`\n */\nexport type RevocationIndeterminateReason =\n\t// Evidence not found\n\t| 'no_applicable_crl'\n\t| 'no_applicable_ocsp'\n\t// Scope issues\n\t| 'distribution_point_mismatch'\n\t| 'issuer_name_mismatch'\n\t| 'reason_scope_mismatch'\n\t| 'indirect_crl_scope_mismatch'\n\t| 'reason_coverage_incomplete'\n\t// Signer trust issues\n\t| 'crl_signer_not_found'\n\t| 'crl_signer_not_authorized'\n\t| 'crl_signer_revoked'\n\t| 'crl_signer_indeterminate'\n\t| 'ocsp_responder_not_found'\n\t| 'ocsp_responder_not_authorized'\n\t| 'ocsp_responder_revoked'\n\t| 'ocsp_responder_indeterminate'\n\t// Freshness\n\t| 'crl_expired'\n\t| 'ocsp_response_expired'\n\t// OCSP specific\n\t| 'ocsp_status_unknown';\n\n/**\n * Identifies the source of revocation evidence.\n *\n * Included in {@linkcode CertificateRevocationStatus.source} when status is\n * `'good'` or `'revoked'` to indicate which CRL or OCSP response provided the answer.\n */\nexport interface RevocationSource {\n\t/** Whether evidence came from a CRL or OCSP response. */\n\treadonly type: 'crl' | 'ocsp';\n\t/** Certificate that signed the evidence (CRL issuer or OCSP responder). */\n\treadonly signerCertificate?: ParsedCertificate;\n\t/** Identifier for debugging (e.g., CRL issuer DN or OCSP responder URL). */\n\treadonly evidenceIdentifier?: string;\n\t/**\n\t * `thisUpdate` of the evidence backing the verdict — the OCSP single\n\t * response entry or the freshest contributing CRL (an applied delta CRL\n\t * supersedes its base). This is the timestamp `'best-available'` compares.\n\t */\n\treadonly thisUpdate?: Date;\n}\n\n/**\n * Revocation evaluation result for a single certificate.\n *\n * One entry per certificate in {@linkcode CheckChainRevocationValue.certificates}.\n * The trust anchor is excluded (never checked for revocation).\n */\nexport interface CertificateRevocationStatus {\n\t/** The certificate that was evaluated. */\n\treadonly certificate: ParsedCertificate;\n\t/**\n\t * Revocation status determination.\n\t *\n\t * - `'good'`: evidence confirms certificate is not revoked\n\t * - `'revoked'`: evidence confirms certificate is revoked\n\t * - `'indeterminate'`: could not determine status (see {@linkcode indeterminateReasons})\n\t */\n\treadonly status: 'good' | 'revoked' | 'indeterminate';\n\t/** Evidence source when status is `'good'` or `'revoked'`. */\n\treadonly source?: RevocationSource;\n\t/** Why status could not be determined. Present when `status` is `'indeterminate'`. */\n\treadonly indeterminateReasons?: readonly RevocationIndeterminateReason[];\n\t/** Revocation details. Present when `status` is `'revoked'`. */\n\treadonly revocationInfo?: {\n\t\t/** When the certificate was revoked. */\n\t\treadonly date: Date;\n\t\t/** RFC 5280 CRLReason code, if provided by the CRL/OCSP response. */\n\t\treadonly reason?: RevocationReason;\n\t};\n}\n\n/**\n * Errors encountered while processing revocation evidence.\n *\n * Distinct from {@linkcode RevocationIndeterminateReason}: execution errors are\n * code failures (malformed CRL, unsupported extension) rather than evaluation\n * outcomes (CRL doesn't cover this certificate).\n *\n * Collected in {@linkcode CheckChainRevocationValue.executionErrors}.\n */\nexport interface RevocationExecutionError {\n\t/** Error category. */\n\treadonly kind: 'parse_error' | 'unsupported_extension' | 'internal_error';\n\t/** Human-readable error description. */\n\treadonly message: string;\n\t/** Which evidence caused the error (e.g., CRL issuer DN). */\n\treadonly evidenceIdentifier?: string;\n}\n\n/**\n * Detailed revocation check results.\n *\n * Returned as {@linkcode CheckChainRevocationResult.value} from\n * {@linkcode checkChainRevocation}. Contains both the policy decision and\n * detailed per-certificate findings for debugging.\n */\nexport interface CheckChainRevocationValue {\n\t/**\n\t * Final policy decision based on {@linkcode RevocationPolicy}.\n\t *\n\t * - `'allow'`: chain passes revocation check\n\t * - `'deny'`: chain fails (revoked certificate or hard-fail on indeterminate)\n\t */\n\treadonly decision: 'allow' | 'deny';\n\t/** Quick-access summary of problematic certificates. */\n\treadonly summary: {\n\t\t/** Certificates confirmed as revoked. */\n\t\treadonly revokedCertificates: readonly ParsedCertificate[];\n\t\t/** Certificates whose status could not be determined. */\n\t\treadonly indeterminateCertificates: readonly ParsedCertificate[];\n\t};\n\t/** Per-certificate evaluation results. See {@linkcode CertificateRevocationStatus}. */\n\treadonly certificates: readonly CertificateRevocationStatus[];\n\t/** Evidence that could not be processed. See {@linkcode RevocationExecutionError}. */\n\treadonly executionErrors?: readonly RevocationExecutionError[];\n}\n\n/** Result type for {@linkcode checkChainRevocation}. */\nexport type CheckChainRevocationResult = {\n\treadonly ok: true;\n\treadonly value: CheckChainRevocationValue;\n};\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Parses a CRL from various source formats.\n */\nfunction parseCrlFromSource(source: CrlSource): ParsedCertificateRevocationList {\n\tif (typeof source === 'object' && 'issuer' in source) {\n\t\treturn source;\n\t}\n\tif (typeof source === 'string') {\n\t\treturn parseCertificateRevocationListPem(source);\n\t}\n\treturn parseCertificateRevocationListDer(source);\n}\n\n/**\n * Parses a certificate from various source formats, returning undefined on failure.\n */\nfunction parseCertificateSafe(source: CertificateSource): ParsedCertificate | undefined {\n\ttry {\n\t\treturn parseCertificateFromSource(source);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Compares two certificates by DER bytes for identity.\n * Reference equality fails when same cert is parsed from different sources.\n */\nfunction sameCertificate(a: ParsedCertificate, b: ParsedCertificate): boolean {\n\tif (a.der.length !== b.der.length) return false;\n\tfor (let i = 0; i < a.der.length; i++) {\n\t\tif (a.der[i] !== b.der[i]) return false;\n\t}\n\treturn true;\n}\n\n/**\n * Searches for a certificate that could have signed the given CRL.\n * Matches by AKI/SKI or issuer/subject DN.\n */\nfunction findIndirectCrlIssuer(\n\tcrl: ParsedCertificateRevocationList,\n\textraCertificates: readonly CertificateSource[],\n\tchain: readonly ParsedCertificate[],\n): ParsedCertificate | undefined {\n\t// Combine extra certs with chain certs for searching\n\t// Chain certs are already parsed; extra certs may need parsing\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...parsedExtras, ...chain];\n\n\t// First pass: prefer AKI/SKI match (more specific)\n\tif (crl.authorityKeyIdentifier !== undefined) {\n\t\tfor (const candidate of candidates) {\n\t\t\tif (\n\t\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\t\tnormalizeHex(crl.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t\t) {\n\t\t\t\treturn candidate;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Second pass: fall back to DN match\n\tfor (const candidate of candidates) {\n\t\tif (crl.issuer.derHex === candidate.subject.derHex) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/** Lowercases a hex string for bytewise comparison. */\nfunction normalizeHex(value: string): string {\n\treturn value.toLowerCase();\n}\n\n// ---------------------------------------------------------------------------\n// CRL Signer Validation (RFC 5280 §6.3.3)\n// ---------------------------------------------------------------------------\n\n/**\n * State machine for CRL signer validation with memoization.\n * - `visiting`: Currently being checked (cycle detection)\n * - `resolved-valid`: Signer is not revoked\n * - `resolved-revoked`: Signer is revoked\n * - `resolved-indeterminate`: Can't determine signer status\n */\ntype SignerValidationState =\n\t| 'visiting'\n\t| 'resolved-valid'\n\t| 'resolved-revoked'\n\t| 'resolved-indeterminate';\n\n/** Context for CRL signer validation with memoization cache. */\ninterface SignerValidationContext {\n\treadonly cache: Map<string, SignerValidationState>;\n\treadonly chain: readonly ParsedCertificate[];\n\treadonly crls: readonly CrlSource[];\n\treadonly extraCertificates: readonly CertificateSource[];\n\treadonly at: Date;\n}\n\n/**\n * Builds a unique cache key for a certificate.\n * Uses issuer DN + serial number which uniquely identifies a cert.\n */\nfunction certCacheKey(cert: ParsedCertificate): string {\n\treturn `${cert.issuer.derHex}:${cert.serialNumberHex}`;\n}\n\n/**\n * Validates that a CRL signer certificate is not revoked.\n * Uses memoization to avoid redundant checks and detect cycles.\n */\nasync function validateCrlSigner(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// Use issuer+serial as cache key (unique per certificate)\n\tconst key = certCacheKey(signer);\n\tconst cached = ctx.cache.get(key);\n\n\t// Cycle detection: if we're already visiting this signer, it's indeterminate\n\tif (cached === 'visiting') {\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Return cached result if already resolved\n\tif (cached !== undefined) {\n\t\treturn cached;\n\t}\n\n\t// Mark as visiting before recursive checks\n\tctx.cache.set(key, 'visiting');\n\n\t// Trust anchor (last in chain) is trusted by definition\n\tconst trustAnchor = ctx.chain[ctx.chain.length - 1];\n\tif (trustAnchor !== undefined && sameCertificate(signer, trustAnchor)) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// If signer is in the validated chain, it's trusted\n\t// (Chain was already validated before revocation checking)\n\tconst isInChain = ctx.chain.some((c) => sameCertificate(c, signer));\n\tif (isInChain) {\n\t\tctx.cache.set(key, 'resolved-valid');\n\t\treturn 'resolved-valid';\n\t}\n\n\t// Signer is not in chain — need to check its revocation status\n\t// Find signer's issuer to perform revocation check\n\tconst signerIssuer = findSignerIssuer(signer, ctx);\n\tif (signerIssuer === undefined) {\n\t\tctx.cache.set(key, 'resolved-indeterminate');\n\t\treturn 'resolved-indeterminate';\n\t}\n\n\t// Check signer's revocation status (recursive)\n\tconst signerRevocation = await checkSignerRevocation(signer, signerIssuer, ctx);\n\tctx.cache.set(key, signerRevocation);\n\treturn signerRevocation;\n}\n\n/**\n * Finds the issuer certificate for a CRL signer.\n * Searches the chain and extraCertificates by AKI/SKI or DN matching.\n */\nfunction findSignerIssuer(\n\tsigner: ParsedCertificate,\n\tctx: SignerValidationContext,\n): ParsedCertificate | undefined {\n\t// Parse extra certificates\n\tconst parsedExtras: ParsedCertificate[] = [];\n\tfor (const source of ctx.extraCertificates) {\n\t\tconst parsed = parseCertificateSafe(source);\n\t\tif (parsed !== undefined) {\n\t\t\tparsedExtras.push(parsed);\n\t\t}\n\t}\n\n\tconst candidates = [...ctx.chain, ...parsedExtras];\n\n\tfor (const candidate of candidates) {\n\t\t// Match by AKI → SKI (preferred, more specific)\n\t\tif (\n\t\t\tsigner.authorityKeyIdentifier !== undefined &&\n\t\t\tcandidate.subjectKeyIdentifier !== undefined &&\n\t\t\tnormalizeHex(signer.authorityKeyIdentifier) === normalizeHex(candidate.subjectKeyIdentifier)\n\t\t) {\n\t\t\treturn candidate;\n\t\t}\n\n\t\t// Match by issuer DN → subject DN\n\t\tif (signer.issuer.derHex === candidate.subject.derHex) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Checks if a CRL signer certificate is revoked by examining available CRLs.\n * Recursively validates the CRL signer of any CRL used to check revocation.\n */\nasync function checkSignerRevocation(\n\tsigner: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tctx: SignerValidationContext,\n): Promise<SignerValidationState> {\n\t// If the signer's issuer is in the validated chain, the signer is trusted\n\t// by virtue of being issued by a trusted CA. We only need to check if\n\t// it's explicitly revoked, not prove \"good\" status.\n\tconst issuerInChain = ctx.chain.some((c) => sameCertificate(c, issuer));\n\n\t// Try each CRL to check signer's revocation\n\tfor (const crlSource of ctx.crls) {\n\t\tlet crl: ParsedCertificateRevocationList;\n\t\ttry {\n\t\t\tcrl = parseCrlFromSource(crlSource);\n\t\t} catch {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check if this CRL can provide revocation info for the signer\n\t\tconst result = await checkCertificateRevocationAgainstCrl({\n\t\t\tcertificate: signer,\n\t\t\tissuerCertificate: issuer,\n\t\t\tcrl,\n\t\t\tat: ctx.at,\n\t\t});\n\n\t\tif (result.ok) {\n\t\t\tif (result.value.status === 'revoked') {\n\t\t\t\treturn 'resolved-revoked';\n\t\t\t}\n\t\t\tif (result.value.status === 'good') {\n\t\t\t\t// Before accepting this result, validate the CRL's signer\n\t\t\t\t// The CRL's signer is the issuer we just used\n\t\t\t\tconst crlSignerStatus = await validateCrlSigner(issuer, ctx);\n\t\t\t\tif (crlSignerStatus === 'resolved-valid') {\n\t\t\t\t\treturn 'resolved-valid';\n\t\t\t\t}\n\t\t\t\t// If CRL signer is revoked or indeterminate, can't trust this result\n\t\t\t}\n\t\t}\n\t}\n\n\t// If the signer's issuer is in the chain and we found no revocation,\n\t// trust the signer (issued by trusted CA, no evidence of revocation)\n\tif (issuerInChain) {\n\t\treturn 'resolved-valid';\n\t}\n\n\treturn 'resolved-indeterminate';\n}\n\n/** Builds a CertificateRevocationStatus for a CRL check result. */\nfunction buildCrlStatus(\n\tcert: ParsedCertificate,\n\tsigner: ParsedCertificate,\n\tstatus: 'good' | 'revoked',\n\tthisUpdate: Date,\n\trevocationDate?: Date,\n\treasonCode?: RevocationReason,\n): CertificateRevocationStatus {\n\tif (status === 'revoked' && revocationDate !== undefined) {\n\t\treturn {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'revoked',\n\t\t\tsource: { type: 'crl', signerCertificate: signer, thisUpdate },\n\t\t\trevocationInfo: {\n\t\t\t\tdate: revocationDate,\n\t\t\t\t...(reasonCode !== undefined ? { reason: reasonCode } : {}),\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\tcertificate: cert,\n\t\tstatus: 'good',\n\t\tsource: { type: 'crl', signerCertificate: signer, thisUpdate },\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// OCSP Evidence Evaluation (RFC 6960)\n// ---------------------------------------------------------------------------\n\n/** Per-certificate evidence evaluation outcome shared by the CRL and OCSP evaluators. */\ninterface EvidenceEvaluation {\n\treadonly status: CertificateRevocationStatus;\n\treadonly executionErrors: readonly RevocationExecutionError[];\n}\n\n/** Parses an OCSP response from PEM string or DER bytes. */\nfunction parseOcspResponseFromSource(source: OcspResponseSource): ParsedOcspResponse {\n\tif (typeof source === 'string') {\n\t\treturn parseOcspResponsePem(source);\n\t}\n\treturn parseOcspResponseDer(source);\n}\n\n/** Maps a {@linkcode validateOcspResponse} failure code to an indeterminate reason. */\nfunction ocspIndeterminateReasonFromFailure(\n\tcode: ValidateOcspResponseFailure['code'],\n): RevocationIndeterminateReason {\n\tswitch (code) {\n\t\tcase 'stale_response':\n\t\t\treturn 'ocsp_response_expired';\n\t\tcase 'responder_id_mismatch':\n\t\tcase 'responder_chain_invalid':\n\t\tcase 'ocsp_signing_missing':\n\t\t\treturn 'ocsp_responder_not_authorized';\n\t\tcase 'responder_revoked':\n\t\t\treturn 'ocsp_responder_revoked';\n\t\tcase 'signature_invalid':\n\t\tcase 'responder_revocation_unknown':\n\t\t\treturn 'ocsp_responder_indeterminate';\n\t\tcase 'response_status_invalid':\n\t\tcase 'issuer_mismatch':\n\t\tcase 'nonce_mismatch':\n\t\tcase 'request_mismatch':\n\t\t\treturn 'no_applicable_ocsp';\n\t}\n}\n\n/** Validation failures worth retrying with an explicit responder certificate. */\nconst OCSP_RESPONDER_FAILURE_CODES: ReadonlySet<ValidateOcspResponseFailure['code']> = new Set([\n\t'signature_invalid',\n\t'responder_id_mismatch',\n\t'responder_chain_invalid',\n\t'ocsp_signing_missing',\n]);\n\n/**\n * Validates an OCSP response, retrying with caller-provided extra certificates\n * as explicit responder certificates when embedded discovery fails.\n */\nasync function validateOcspResponseWithResponderFallback(\n\tresponse: ParsedOcspResponse,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tat: Date,\n): Promise<ValidateOcspResponseResult> {\n\tconst shared = {\n\t\tissuerCertificate: issuer,\n\t\tat,\n\t\t...(input.trustedOcspResponders !== undefined\n\t\t\t? { trustedResponderCertificates: input.trustedOcspResponders }\n\t\t\t: {}),\n\t\t...(input.policy?.ocspResponderRevocation !== undefined\n\t\t\t? { responderRevocationPolicy: input.policy.ocspResponderRevocation }\n\t\t\t: {}),\n\t\t// Chain-level CRLs double as responder revocation evidence\n\t\t...(input.crls !== undefined ? { responderRevocationCrls: input.crls } : {}),\n\t};\n\tconst primary = await validateOcspResponse({ response, ...shared });\n\tif (primary.ok || !OCSP_RESPONDER_FAILURE_CODES.has(primary.code)) {\n\t\treturn primary;\n\t}\n\tfor (const source of input.extraCertificates ?? []) {\n\t\tconst responder = parseCertificateSafe(source);\n\t\tif (responder === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst retry = await validateOcspResponse({\n\t\t\tresponse,\n\t\t\t...shared,\n\t\t\tresponderCertificate: responder,\n\t\t});\n\t\tif (retry.ok) {\n\t\t\treturn retry;\n\t\t}\n\t}\n\treturn primary;\n}\n\n/**\n * Evaluates OCSP evidence for a single certificate (RFC 6960).\n *\n * Every response is fully validated — signature, responder binding and\n * authorization, and freshness — via {@linkcode validateOcspResponse} before\n * its status entry is trusted. Issuer binding of each CertID is enforced by\n * the validator, so a serial-number match on a validated response is\n * sufficient to attribute the entry to `cert`.\n */\nasync function evaluateOcspEvidence(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n): Promise<EvidenceEvaluation> {\n\tconst { ocspResponses = [], at = new Date() } = input;\n\tconst executionErrors: RevocationExecutionError[] = [];\n\tconst reasons = new Set<RevocationIndeterminateReason>();\n\n\tfor (const source of ocspResponses) {\n\t\tlet parsed: ParsedOcspResponse;\n\t\ttry {\n\t\t\tparsed = parseOcspResponseFromSource(source);\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'OCSP response parse failed',\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst entry = (parsed.responses ?? []).find(\n\t\t\t(single) =>\n\t\t\t\tnormalizeHex(single.certId.serialNumberHex) === normalizeHex(cert.serialNumberHex),\n\t\t);\n\t\tif (entry === undefined) {\n\t\t\tcontinue; // Response does not cover this certificate\n\t\t}\n\n\t\tconst validation = await validateOcspResponseWithResponderFallback(parsed, issuer, input, at);\n\t\tif (!validation.ok) {\n\t\t\treasons.add(ocspIndeterminateReasonFromFailure(validation.code));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.certStatus === 'revoked') {\n\t\t\tconst reason = revocationReasonFromCode(entry.revocationReasonCode);\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'revoked',\n\t\t\t\t\tsource: { type: 'ocsp', thisUpdate: entry.thisUpdate },\n\t\t\t\t\trevocationInfo: {\n\t\t\t\t\t\tdate: entry.revokedAt ?? entry.thisUpdate,\n\t\t\t\t\t\t...(reason !== undefined ? { reason } : {}),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\tif (entry.certStatus === 'good') {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\tsource: { type: 'ocsp', thisUpdate: entry.thisUpdate },\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\treasons.add('ocsp_status_unknown');\n\t}\n\n\tif (reasons.size === 0) {\n\t\treasons.add('no_applicable_ocsp');\n\t}\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [...reasons],\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n/**\n * Evaluates revocation status for a single certificate using available CRLs.\n * Returns both status and any execution errors encountered.\n *\n * Tries the chain issuer first; if that fails, searches extraCertificates\n * and chain for an indirect CRL issuer that matches the CRL's AKI or issuer DN.\n *\n * Also validates that CRL signers are not revoked (RFC 5280 §6.3.3).\n */\n// RFC 5280 ReasonFlags — all possible revocation reasons that CRLs can cover.\nconst ALL_REASON_FLAGS: readonly string[] = [\n\t'keyCompromise',\n\t'cACompromise',\n\t'affiliationChanged',\n\t'superseded',\n\t'cessationOfOperation',\n\t'certificateHold',\n\t'privilegeWithdrawn',\n\t'aACompromise',\n];\n\nasync function evaluateCrlEvidence(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<EvidenceEvaluation> {\n\tconst { crls = [], extraCertificates = [], chain = [], at = new Date() } = input;\n\tconst executionErrors: RevocationExecutionError[] = [];\n\tlet sawCrlSignerRevoked = false;\n\tlet sawCrlSignerIndeterminate = false;\n\tlet sawGood = false;\n\t// Signer and thisUpdate are tracked together so the reported\n\t// signerCertificate always belongs to the CRL whose freshness is reported.\n\tlet freshestGood: { readonly signer: ParsedCertificate; readonly thisUpdate: Date } | undefined;\n\tconst coveredReasons = new Set<string>();\n\n\t// Parse all CRLs and separate base CRLs from delta CRLs\n\tconst parsedCrls: ParsedCertificateRevocationList[] = [];\n\tfor (const crlSource of crls) {\n\t\ttry {\n\t\t\tparsedCrls.push(parseCrlFromSource(crlSource));\n\t\t} catch (e) {\n\t\t\texecutionErrors.push({\n\t\t\t\tkind: 'parse_error',\n\t\t\t\tmessage: e instanceof Error ? e.message : 'CRL parse failed',\n\t\t\t});\n\t\t}\n\t}\n\n\tconst baseCrls = parsedCrls.filter((crl) => crl.baseCrlNumber === undefined);\n\tconst deltaCrls = parsedCrls.filter((crl) => crl.baseCrlNumber !== undefined);\n\n\t// Helper to check CRL with given issuer and optional delta\n\tconst checkWithIssuer = async (\n\t\tcrl: ParsedCertificateRevocationList,\n\t\tdeltaCrl: ParsedCertificateRevocationList | undefined,\n\t\tcrlIssuer: ParsedCertificate,\n\t) => {\n\t\treturn checkCertificateRevocationAgainstCrl({\n\t\t\tcertificate: cert,\n\t\t\tissuerCertificate: crlIssuer,\n\t\t\tcrl,\n\t\t\t...(deltaCrl !== undefined ? { deltaCrl } : {}),\n\t\t\tat,\n\t\t});\n\t};\n\n\t// Process base CRLs (optionally paired with delta CRLs)\n\tfor (const baseCrl of baseCrls) {\n\t\t// Find applicable delta CRL for this base CRL (if any)\n\t\t// Delta CRL applies if it has the same issuer and crlNumber matches baseCrlNumber\n\t\tconst applicableDelta = deltaCrls.find(\n\t\t\t(d) =>\n\t\t\t\td.issuer.derHex === baseCrl.issuer.derHex &&\n\t\t\t\td.baseCrlNumber !== undefined &&\n\t\t\t\tbaseCrl.crlNumber !== undefined &&\n\t\t\t\tBigInt(d.baseCrlNumber) <= BigInt(baseCrl.crlNumber),\n\t\t);\n\n\t\t// Try chain issuer first\n\t\tlet result = await checkWithIssuer(baseCrl, applicableDelta, issuer);\n\t\tlet effectiveSigner = issuer;\n\n\t\t// Chain issuer failed — try to find indirect CRL issuer\n\t\tif (!result.ok) {\n\t\t\tconst indirectIssuer = findIndirectCrlIssuer(baseCrl, extraCertificates, chain);\n\t\t\tif (indirectIssuer !== undefined && !sameCertificate(indirectIssuer, issuer)) {\n\t\t\t\tresult = await checkWithIssuer(baseCrl, applicableDelta, indirectIssuer);\n\t\t\t\teffectiveSigner = indirectIssuer;\n\t\t\t}\n\t\t}\n\n\t\tif (!result.ok) {\n\t\t\tcontinue; // CRL doesn't apply to this certificate\n\t\t}\n\n\t\t// Validate CRL signer is not revoked before accepting result\n\t\tconst signerStatus = await validateCrlSigner(effectiveSigner, signerCtx);\n\t\tif (signerStatus === 'resolved-revoked') {\n\t\t\tsawCrlSignerRevoked = true;\n\t\t\tcontinue; // CRL signer revoked — can't trust this CRL\n\t\t}\n\t\tif (signerStatus === 'resolved-indeterminate') {\n\t\t\tsawCrlSignerIndeterminate = true;\n\t\t\tcontinue; // CRL signer status unknown — try other CRLs\n\t\t}\n\n\t\t// Evidence freshness: an applied delta CRL supersedes its base\n\t\tconst crlThisUpdate =\n\t\t\tapplicableDelta !== undefined &&\n\t\t\tapplicableDelta.thisUpdate.getTime() > baseCrl.thisUpdate.getTime()\n\t\t\t\t? applicableDelta.thisUpdate\n\t\t\t\t: baseCrl.thisUpdate;\n\n\t\t// CRL is valid — check result\n\t\tif (result.value.status === 'revoked') {\n\t\t\t// Immediately return revoked status\n\t\t\treturn {\n\t\t\t\tstatus: buildCrlStatus(\n\t\t\t\t\tcert,\n\t\t\t\t\teffectiveSigner,\n\t\t\t\t\t'revoked',\n\t\t\t\t\tcrlThisUpdate,\n\t\t\t\t\tresult.value.revocationDate,\n\t\t\t\t\tresult.value.reasonCode,\n\t\t\t\t),\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\n\t\t// Status is 'good' — track which reasons this CRL covers\n\t\tsawGood = true;\n\t\tif (freshestGood === undefined || crlThisUpdate.getTime() > freshestGood.thisUpdate.getTime()) {\n\t\t\tfreshestGood = { signer: effectiveSigner, thisUpdate: crlThisUpdate };\n\t\t}\n\t\tconst crlReasons = baseCrl.issuingDistributionPoint?.onlySomeReasons?.flags;\n\t\tif (crlReasons === undefined) {\n\t\t\t// CRL covers all reasons\n\t\t\tfor (const reason of ALL_REASON_FLAGS) {\n\t\t\t\tcoveredReasons.add(reason);\n\t\t\t}\n\t\t} else {\n\t\t\t// CRL only covers specific reasons\n\t\t\tfor (const reason of crlReasons) {\n\t\t\t\tcoveredReasons.add(reason);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Return 'good' only if we saw at least one good result AND all reasons are covered\n\tif (sawGood) {\n\t\tconst allReasonsCovered = ALL_REASON_FLAGS.every((r) => coveredReasons.has(r));\n\t\tif (allReasonsCovered) {\n\t\t\treturn {\n\t\t\t\tstatus: {\n\t\t\t\t\tcertificate: cert,\n\t\t\t\t\tstatus: 'good',\n\t\t\t\t\t...(freshestGood !== undefined\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tsource: {\n\t\t\t\t\t\t\t\t\ttype: 'crl',\n\t\t\t\t\t\t\t\t\tsignerCertificate: freshestGood.signer,\n\t\t\t\t\t\t\t\t\tthisUpdate: freshestGood.thisUpdate,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: {}),\n\t\t\t\t},\n\t\t\t\texecutionErrors,\n\t\t\t};\n\t\t}\n\t\t// Not all reasons covered — indeterminate\n\t\treturn {\n\t\t\tstatus: {\n\t\t\t\tcertificate: cert,\n\t\t\t\tstatus: 'indeterminate',\n\t\t\t\tindeterminateReasons: ['reason_coverage_incomplete'],\n\t\t\t},\n\t\t\texecutionErrors,\n\t\t};\n\t}\n\n\t// No applicable CRL found — determine most appropriate indeterminate reason\n\tconst reasons: RevocationIndeterminateReason[] = [];\n\tif (sawCrlSignerRevoked) {\n\t\treasons.push('crl_signer_revoked');\n\t} else if (sawCrlSignerIndeterminate) {\n\t\treasons.push('crl_signer_indeterminate');\n\t} else {\n\t\treasons.push('no_applicable_crl');\n\t}\n\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: reasons,\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n/**\n * Evaluates revocation status for a single certificate by combining OCSP and\n * CRL evidence.\n *\n * Both evidence kinds are always evaluated: a validated `revoked` verdict from\n * either source wins regardless of {@linkcode RevocationPolicy.prefer}\n * (fail-closed). Otherwise the preferred source's `good` verdict is reported —\n * for `'best-available'` the source with the later evidence `thisUpdate` wins,\n * ties favoring OCSP. If neither source is definitive, indeterminate reasons\n * from both are merged.\n */\nasync function evaluateCertificateRevocation(\n\tcert: ParsedCertificate,\n\tissuer: ParsedCertificate,\n\tinput: CheckChainRevocationInput,\n\tsignerCtx: SignerValidationContext,\n): Promise<EvidenceEvaluation> {\n\tconst prefer = input.policy?.prefer ?? 'best-available';\n\tconst ocsp = await evaluateOcspEvidence(cert, issuer, input);\n\tconst crl = await evaluateCrlEvidence(cert, issuer, input, signerCtx);\n\tconst executionErrors = [...ocsp.executionErrors, ...crl.executionErrors];\n\n\t// 'best-available' ranks by evidence freshness; the sort is stable, so\n\t// equal (or absent) thisUpdate keeps OCSP first.\n\tconst ordered =\n\t\tprefer === 'crl'\n\t\t\t? [crl, ocsp]\n\t\t\t: prefer === 'ocsp'\n\t\t\t\t? [ocsp, crl]\n\t\t\t\t: [ocsp, crl].sort(\n\t\t\t\t\t\t(a, b) =>\n\t\t\t\t\t\t\t(b.status.source?.thisUpdate?.getTime() ?? 0) -\n\t\t\t\t\t\t\t(a.status.source?.thisUpdate?.getTime() ?? 0),\n\t\t\t\t\t);\n\tconst revoked = ordered.find((evaluation) => evaluation.status.status === 'revoked');\n\tif (revoked !== undefined) {\n\t\treturn { status: revoked.status, executionErrors };\n\t}\n\tconst good = ordered.find((evaluation) => evaluation.status.status === 'good');\n\tif (good !== undefined) {\n\t\treturn { status: good.status, executionErrors };\n\t}\n\n\tconst reasons = new Set<RevocationIndeterminateReason>();\n\tfor (const evaluation of ordered) {\n\t\tfor (const reason of evaluation.status.indeterminateReasons ?? []) {\n\t\t\treasons.add(reason);\n\t\t}\n\t}\n\treturn {\n\t\tstatus: {\n\t\t\tcertificate: cert,\n\t\t\tstatus: 'indeterminate',\n\t\t\tindeterminateReasons: [...reasons],\n\t\t},\n\t\texecutionErrors,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Function\n// ---------------------------------------------------------------------------\n\n/**\n * Checks revocation status for all certificates in a validated chain.\n *\n * Evaluates CRL and OCSP evidence against each certificate (except the trust\n * anchor), applies the revocation policy, and returns a unified decision.\n *\n * @example\n * ```ts\n * const result = await checkChainRevocation({\n * chain: validatedChain,\n * crls: [crl1, crl2],\n * ocspResponses: [ocspResponseDer],\n * policy: { mode: 'hard-fail' },\n * });\n * if (result.value.decision === 'deny') {\n * console.log('Revocation check failed');\n * }\n * ```\n */\nexport async function checkChainRevocation(\n\tinput: CheckChainRevocationInput,\n): Promise<CheckChainRevocationResult> {\n\tconst { chain, policy, crls = [], extraCertificates = [], at = new Date() } = input;\n\tconst mode = policy?.mode ?? 'soft-fail';\n\n\t// Empty chain → allow\n\tif (chain.length === 0) {\n\t\treturn {\n\t\t\tok: true,\n\t\t\tvalue: {\n\t\t\t\tdecision: 'allow',\n\t\t\t\tsummary: { revokedCertificates: [], indeterminateCertificates: [] },\n\t\t\t\tcertificates: [],\n\t\t\t},\n\t\t};\n\t}\n\n\t// Create signer validation context with memoization cache\n\t// This cache is shared across all certificate checks in this chain evaluation\n\tconst signerCtx: SignerValidationContext = {\n\t\tcache: new Map(),\n\t\tchain,\n\t\tcrls,\n\t\textraCertificates,\n\t\tat,\n\t};\n\n\t// Skip trust anchor (last cert) — it's the trust base\n\tconst certsToCheck = chain.slice(0, -1);\n\tconst certificates: CertificateRevocationStatus[] = [];\n\tconst revokedCertificates: ParsedCertificate[] = [];\n\tconst indeterminateCertificates: ParsedCertificate[] = [];\n\tconst allExecutionErrors: RevocationExecutionError[] = [];\n\n\tfor (let i = 0; i < certsToCheck.length; i++) {\n\t\tconst cert = certsToCheck[i];\n\t\tconst issuer = chain[i + 1]; // Next cert in chain is the issuer\n\t\tif (cert === undefined || issuer === undefined) {\n\t\t\tcontinue; // Should never happen given loop bounds\n\t\t}\n\n\t\tconst { status, executionErrors } = await evaluateCertificateRevocation(\n\t\t\tcert,\n\t\t\tissuer,\n\t\t\tinput,\n\t\t\tsignerCtx,\n\t\t);\n\t\tcertificates.push(status);\n\t\tallExecutionErrors.push(...executionErrors);\n\n\t\tif (status.status === 'revoked') {\n\t\t\trevokedCertificates.push(cert);\n\t\t} else if (status.status === 'indeterminate') {\n\t\t\tindeterminateCertificates.push(cert);\n\t\t}\n\t}\n\n\t// Apply policy\n\tconst hasRevoked = revokedCertificates.length > 0;\n\tconst hasIndeterminate = indeterminateCertificates.length > 0;\n\tconst decision: 'allow' | 'deny' = hasRevoked\n\t\t? 'deny'\n\t\t: hasIndeterminate && mode === 'hard-fail'\n\t\t\t? 'deny'\n\t\t\t: 'allow';\n\n\treturn {\n\t\tok: true,\n\t\tvalue: {\n\t\t\tdecision,\n\t\t\tsummary: { revokedCertificates, indeterminateCertificates },\n\t\t\tcertificates,\n\t\t\t...(allExecutionErrors.length > 0 ? { executionErrors: allExecutionErrors } : {}),\n\t\t},\n\t};\n}\n"],"mappings":"+UAwQA,SAAS,EAAmB,EAAoD,CAO/E,OANI,OAAO,GAAW,UAAY,WAAY,EACtC,EAEJ,OAAO,GAAW,SACd,EAAkC,CAAM,EAEzC,EAAkC,CAAM,CAChD,CAKA,SAAS,EAAqB,EAA0D,CACvF,GAAI,CACH,OAAO,EAA2B,CAAM,CACzC,MAAQ,CACP,MACD,CACD,CAMA,SAAS,EAAgB,EAAsB,EAA+B,CAC7E,GAAI,EAAE,IAAI,SAAW,EAAE,IAAI,OAAQ,MAAO,GAC1C,IAAK,IAAI,EAAI,EAAG,EAAI,EAAE,IAAI,OAAQ,IACjC,GAAI,EAAE,IAAI,KAAO,EAAE,IAAI,GAAI,MAAO,GAEnC,MAAO,EACR,CAMA,SAAS,EACR,EACA,EACA,EACgC,CAGhC,IAAM,EAAoC,CAAC,EAC3C,IAAK,IAAM,KAAU,EAAmB,CACvC,IAAM,EAAS,EAAqB,CAAM,EACtC,IAAW,IAAA,IACd,EAAa,KAAK,CAAM,CAE1B,CAEA,IAAM,EAAa,CAAC,GAAG,EAAc,GAAG,CAAK,EAG7C,GAAI,EAAI,yBAA2B,IAAA,QAC7B,IAAM,KAAa,EACvB,GACC,EAAU,uBAAyB,IAAA,IACnC,EAAa,EAAI,sBAAsB,IAAM,EAAa,EAAU,oBAAoB,EAExF,OAAO,CAAA,CAMV,IAAK,IAAM,KAAa,EACvB,GAAI,EAAI,OAAO,SAAW,EAAU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A,IAAM,EAAa,EAAoB,OAAS,EAC1C,EAAmB,EAA0B,OAAS,EAO5D,MAAO,CACN,GAAI,GACJ,MAAO,CACN,SATiC,GAEhC,GAAoB,IAAS,YAD7B,OAGC,QAMF,QAAS,CAAE,sBAAqB,2BAA0B,EAC1D,eACA,GAAI,EAAmB,OAAS,EAAI,CAAE,gBAAiB,CAAmB,EAAI,CAAC,CAChF,CACD,CACD"}
|
package/dist/revocation/crl.d.ts
CHANGED
|
@@ -311,6 +311,8 @@ declare function checkCertificateRevocationAgainstCrl(input: CheckCertificateRev
|
|
|
311
311
|
* CRL's revoked entries. Does **not** validate the CRL or check applicability.
|
|
312
312
|
*/
|
|
313
313
|
declare function isCertificateRevoked(certificateSerialNumber: Uint8Array | string, crl: ParsedCertificateRevocationList): boolean;
|
|
314
|
+
/** Maps an integer CRLReason code back to its {@linkcode RevocationReason} string, or `undefined` for unknown codes. */
|
|
315
|
+
declare function revocationReasonFromCode(code: number | undefined): RevocationReason | undefined;
|
|
314
316
|
//#endregion
|
|
315
|
-
export { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlSource, ParsedCertificateRevocationList, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListFailure, VerifyCertificateRevocationListResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListPem, validateCertificateRevocationList, verifyCertificateRevocationList };
|
|
317
|
+
export { CertificateRevocationListMaterial, CheckCertificateRevocationAgainstCrlErrorCode, CheckCertificateRevocationAgainstCrlFailure, CheckCertificateRevocationAgainstCrlFailureDetails, CheckCertificateRevocationAgainstCrlGoodValue, CheckCertificateRevocationAgainstCrlInput, CheckCertificateRevocationAgainstCrlResult, CheckCertificateRevocationAgainstCrlRevokedValue, CheckCertificateRevocationAgainstCrlValue, CreateCertificateRevocationListInput, CrlApplicabilityFailureReason, CrlCertificateSource, CrlSource, ParsedCertificateRevocationList, ParsedRevokedCertificate, RevocationReason, RevokedCertificateInput, ValidateCertificateRevocationListFailure, ValidateCertificateRevocationListInput, ValidateCertificateRevocationListResult, VerifyCertificateRevocationListFailure, VerifyCertificateRevocationListResult, checkCertificateRevocationAgainstCrl, createCertificateRevocationList, isCertificateRevoked, parseCertificateRevocationListDer, parseCertificateRevocationListPem, revocationReasonFromCode, validateCertificateRevocationList, verifyCertificateRevocationList };
|
|
316
318
|
//# sourceMappingURL=crl.d.ts.map
|