silk.tls.certificate_path.
Validate the certificate chain of a TLS server, from its leaf certificate to a trust anchor.
When to use#
Call CertificatePath.validate with the certificates that a server sent and your
TrustAnchor list, before you trust the server. After it succeeds, check the host name with
silk.tls.https_identity, and check the TLS CertificateVerify and Finished messages.
silk.tls.client does all of these steps for you.
Details#
The validator tries to build a path from the leaf, through the intermediates, to an anchor. At
each step it tries the anchors first and then the intermediates, in the order that you gave
them, and it backtracks when a candidate fails. It checks signatures, validity dates at the
Instant that you give, basic constraints, key usage, path length, and DNS and IP name
constraints. ValidationLimits bound all work, so a hostile chain cannot make it run for
long.
Errors#
ValidationErrorif no valid path exists, an input is not valid, or a limit is exceeded.reason,location, andoffsettell you what failed and where.OutOfMemoryErrorif theAllocatorfails.
Gotchas#
A ValidatedPath does not authenticate a TLS connection by itself. Revocation (CRL and OCSP),
certificate transparency, fetching missing intermediates, and browser root policies are not
checked.
Import as CertificatePath with import silk.tls.certificate_path { CertificatePath }.
Public declarations: 9.
ValidationLimits#
pub struct ValidationLimitsThe limits for one validation call. Each limit is inclusive, and 0 allows nothing.
ValidationLimits.defaults gives safe values.
Field peerCertificates#
pub peerCertificates: usizeMaximum peer certificates, including the leaf.
Field certificateBytes#
pub certificateBytes: usizeMaximum DER bytes in each peer certificate.
Field peerBytes#
pub peerBytes: usizeMaximum aggregate peer certificate DER bytes.
Field anchors#
pub anchors: usizeMaximum explicit trust-anchor candidates.
Field anchorBytes#
pub anchorBytes: usizeMaximum aggregate encoded trust-anchor bytes.
Field pathCertificates#
pub pathCertificates: usizeMaximum selected path certificates, excluding the anchor and including the leaf.
Field issuerCandidates#
pub issuerCandidates: usizeMaximum issuer-candidate visits.
Field signatureVerifications#
pub signatureVerifications: usizeMaximum primitive signature verifications.
Field completePaths#
pub completePaths: usizeMaximum reached anchored candidate paths.
Field nameComparisons#
pub nameComparisons: usizeMaximum DNS or IP name/subtree comparisons.
Field profile#
pub profile: ProfileLimitsBounds for each semantic certificate-profile inspection.
Implementation Copy for ValidationLimits#
impl Copy for ValidationLimitsImplementation ValidationLimits#
impl ValidationLimitsAssociated function defaults#
pub fn defaults() -> ValidationLimitsReturns the default limits: 64 peer certificates of up to 64 KiB each and 1 MiB in total, 1024 anchors and 16 MiB of anchor data, paths of up to 8 certificates, 4096 issuer candidates, 100 signature checks, 100 complete paths, 250000 name comparisons, and the profile defaults.
ValidationClass#
pub enum ValidationClassThe broad category of a path-validation failure.
InvalidInput#
InvalidInputCaller input is invalid independently of trust-path selection.
Rejected#
RejectedThe fixed certificate policy rejects all deterministic candidate paths.
ResourceLimit#
ResourceLimitAn inclusive caller-supplied resource or work bound is exceeded.
Implementation Debug for ValidationClass#
impl Debug for ValidationClassOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as InvalidInput.
ValidationReason#
pub enum ValidationReasonStable path-validation rejection reasons.
UnsupportedVersion#
UnsupportedVersionThe certificate version is outside the fixed role profile.
UnsupportedAlgorithm#
UnsupportedAlgorithmA required signature or key algorithm is unsupported.
UnsupportedParameters#
UnsupportedParametersAlgorithm parameters are unsupported or inconsistent.
UnsupportedExtension#
UnsupportedExtensionAn extension needs unsupported processing.
UnsupportedConstraint#
UnsupportedConstraintA NameConstraints form is outside the DNS/IP subset.
UnsupportedPolicy#
UnsupportedPolicyCertificate policy processing is required but not implemented.
InvalidKey#
InvalidKeyA public key is malformed or outside the admitted profile.
InvalidSignature#
InvalidSignatureA retained certificate signature does not verify.
InvalidSerial#
InvalidSerialA path-certificate serial is invalid.
InvalidUsage#
InvalidUsageKeyUsage or ExtendedKeyUsage rejects the selected role.
InvalidBasicConstraints#
InvalidBasicConstraintsBasicConstraints or CA-role policy rejects the certificate.
InvalidName#
InvalidNameA subject name or subjectAltName is invalid.
InvalidTime#
InvalidTimeA caller instant or certificate validity interval is invalid.
DuplicateExtension#
DuplicateExtensionTwo extensions contain the same OID.
IssuerMismatch#
IssuerMismatchExact issuer and subject Name DER do not match.
NameConstraintViolation#
NameConstraintViolationA subordinate SAN violates cumulative NameConstraints.
PathLengthExceeded#
PathLengthExceededAn embedded or configured path-length restriction is exceeded.
Cycle#
CycleA linked candidate repeats certificate DER already on the current path.
NoIssuer#
NoIssuerNo supplied candidate has an exact linking subject Name.
NoValidPath#
NoValidPathEvery deterministically visited linked path is rejected.
SizeOverflow#
SizeOverflowA checked length or counter sum is not representable.
Implementation Debug for ValidationReason#
impl Debug for ValidationReasonOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as UnsupportedVersion.
ValidationLocation#
pub union ValidationLocationThe input position associated with one validation failure.
Leaf#
LeafThe peer end-entity certificate.
Intermediate#
IntermediateOne peer intermediate at its original caller index.
Field index#
pub index: usizeThe original caller index.
Anchor#
AnchorOne explicit trust anchor at its original caller index.
Field index#
pub index: usizeThe original caller index.
Call#
CallThe validation call rather than one certificate.
Implementation Copy for ValidationLocation#
impl Copy for ValidationLocationImplementation Debug for ValidationLocation#
impl Debug for ValidationLocationOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant and its fields, such as Leaf.
ValidationLimit#
pub enum ValidationLimitA named inclusive validation bound.
PeerCertificates#
PeerCertificatesTotal peer certificate count, including the leaf.
CertificateBytes#
CertificateBytesDER bytes in one peer certificate.
PeerBytes#
PeerBytesAggregate peer certificate DER bytes.
Anchors#
AnchorsExplicit trust-anchor count.
AnchorBytes#
AnchorBytesAggregate encoded trust-anchor bytes.
PathCertificates#
PathCertificatesSelected path certificate count, excluding the anchor.
IssuerCandidates#
IssuerCandidatesIssuer-candidate visits.
SignatureVerifications#
SignatureVerificationsPrimitive signature verifications.
CompletePaths#
CompletePathsComplete anchored candidate paths.
NameComparisons#
NameComparisonsDNS or IP name/subtree comparisons.
ProfileExtensions#
ProfileExtensionsCertificate-profile extension count.
ProfileExtensionBytes#
ProfileExtensionBytesOne certificate-profile extension value size.
ProfileSanNames#
ProfileSanNamesCertificate-profile subjectAltName count.
ProfileConstraintSubtrees#
ProfileConstraintSubtreesCertificate-profile NameConstraints subtree count.
ProfileNodes#
ProfileNodesCertificate-profile DER-node count.
ProfileDepth#
ProfileDepthCertificate-profile DER nesting depth.
Arithmetic#
ArithmeticChecked arithmetic representation.
Implementation Debug for ValidationLimit#
impl Debug for ValidationLimitOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the name of the variant, such as PeerCertificates.
ValidationError#
pub struct ValidationErrorThe error of one failed CertificatePath.validate call.
Details#
reason, location, and offset tell what failed and where. When no path is valid, reason
is NoValidPath and detailReason gives the first rejection. It owns its values and does not
borrow the input.
Field kind#
pub kind: ValidationClassBroad failure category.
Field reason#
pub reason: ValidationReasonStable primary reason.
Field detailReason#
pub detailReason: Option<ValidationReason>First rejected-candidate detail when reason is NoValidPath.
Field location#
pub location: ValidationLocationInput position associated with the primary or retained detail.
Field extensionIndex#
pub extensionIndex: Option<usize>Extension index when a profile failure belongs to an extension.
Field limit#
pub limit: Option<ValidationLimit>Named bound for a resource-limit failure.
Field offset#
pub offset: usizeByte offset in the relevant certificate or configured constraint input.
Implementation Debug for ValidationError#
impl Debug for ValidationErrorOperation debug#
effect fn debug(self: &Self, formatter: &mut Formatter) -> () ! WriterError ? &mut WriterWrites the fields, as ValidationError { kind: ..., reason: ..., ... }.
RevocationStatus#
pub enum RevocationStatusRevocation evidence attached to a validated path.
NotChecked#
NotCheckedNo CRL, OCSP, must-staple, or other revocation check was performed.
ValidatedPath#
pub struct ValidatedPath<'a>A path that passed validation. It borrows the certificates and anchors that you gave.
The intermediates are given as indexes into your list, from the leaf toward the anchor.
Gotchas#
A validated path does not authenticate a TLS connection by itself. Check the host name with
silk.tls.https_identity, and check the TLS CertificateVerify and Finished messages. Revocation
(CRL and OCSP), certificate transparency, fetching missing intermediates, and browser root
policies are not checked.
Implementation ValidatedPath<'a>#
impl<'a> ValidatedPath<'a>Method leaf#
pub fn leaf(self: &Self) -> &'a CertificateReturns the leaf certificate.
Method anchorIndex#
pub fn anchorIndex(self: &Self) -> usizeReturns the index of the trust anchor that the path ends at, in your anchor list.
Method intermediateCount#
pub fn intermediateCount(self: &Self) -> usizeReturns the number of intermediate certificates in the path.
Method intermediateIndex#
pub fn intermediateIndex(self: &Self, index: usize) -> Option<usize>Returns the index in your intermediate list of the path certificate at index, counted from
the leaf, or None if index is out of range.
Method validationTime#
pub fn validationTime(self: &Self) -> InstantReturns the time that the dates were checked at.
Method revocationStatus#
pub fn revocationStatus(self: &Self) -> RevocationStatusReturns NotChecked, because path validation does not check revocation.
CertificatePath#
pub struct CertificatePathFunctions that validate the certificate chain of a TLS server, from its leaf certificate to a trust anchor.
When to use#
Call CertificatePath.validate with the certificates that a server sent and your
TrustAnchor list, before you trust the server. silk.tls.client does this and the other
TLS checks for you.
Gotchas#
A ValidatedPath does not authenticate a TLS connection by itself. Revocation (CRL and OCSP),
certificate transparency, fetching missing intermediates, and browser root policies are not
checked.
Implementation CertificatePath#
impl CertificatePathAssociated function validate#
pub effect fn validate<'a>(
leaf: &'a Certificate,
intermediates: &'a [Certificate],
anchors: &'a [TrustAnchor],
at: &Instant,
limits: ValidationLimits,
) -> Result<ValidatedPath<'a>, ValidationError>
! OutOfMemoryError
? &mut AllocatorFinds and checks a path from leaf through intermediates to one of anchors, at time at.
At each step it tries the anchors first and then the intermediates, in the order that you
gave them, and it backtracks when a candidate fails. It checks signatures, validity dates at
at, basic constraints, key usage, path length, and DNS and IP name constraints. limits
bound all work, so a hostile chain cannot make it run for long.
It returns the first valid path that it finds. A candidate that fails does not stop the
search, but each limit counts across the whole call. The result borrows leaf,
intermediates, and anchors.
Errors#
Failurewith aValidationError. If no path is valid,reasonisNoValidPathanddetailReasongives the first rejection.OutOfMemoryErrorif theAllocatorfails.
Gotchas#
A valid path does not authenticate a TLS connection by itself. After it succeeds, check the
host name with silk.tls.https_identity, and check the TLS CertificateVerify and Finished
messages. Revocation (CRL and OCSP), certificate transparency, fetching missing
intermediates, and browser root policies are not checked.
Category: TLS and certificates.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.