Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Structs X509CertificateStore

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module juptune.data.x509.store;

struct X509CertificateStore
{
    /++ STRUCTS ++/
    
    /// An aggregate type storing a bunch of information about an x.509 certificate. 
    static struct Cert
    {
        /++ ALIASES ++/
        
        ///
        alias __xdtor = __MARMOS_BUG__;
        ///
        alias __xpostblit = __MARMOS_BUG__;
        
        /++ FUNCTIONS ++/
        
        ///
        X509CertificateStore.Cert opAssign(X509CertificateStore.Cert p);
        
        /++ VARIABLES ++/
        
        ///
        X509Certificate certificate;
        ///
        X509ExtensionStore extensions;
    }
    ///
    static struct SecurityPolicy
    {
        /++ FUNCTIONS ++/
        
        ///
        X509CertificateStore.SecurityPolicy withAllowSelfSignedChain(bool allow);
        
        /++ VARIABLES ++/
        
        /// Please see the documentation for validateChainFromCopyingDerBytes . 
        bool allowSelfSignedChain;
    }
    
    /++ ALIASES ++/
    
    ///
    alias __xdtor = __MARMOS_BUG__;
    /// Iterates over all certificates found inside of the store, and calls the user provided callback on all of them. 
    alias foreachCert = __MARMOS_BUG__;
    ///
    alias foreachCertGc = __MARMOS_BUG__;
    /// Validates a chain of certificates (or a "chain" with a single certificate) from the given raw DER encoded bytes. These certificates are not loaded into the store, and are immediately freed upon exit of this function. 
    alias validateChainFromCopyingDerBytes = __MARMOS_BUG__;
    ///
    alias validateChainFromCopyingDerBytesGC = __MARMOS_BUG__;
    
    /++ FUNCTIONS ++/
    
    /// Looks up a certificate by its subjectKeyIdentifier, or null if no certificate was found. 
    X509CertificateStore.Cert* getBySubjectKeyIdOrNull(const ubyte[] subjectKeyId);
    /// Loads a certificate bundle from the given PEM encoded data. 
    Result loadBundleFromPem(const char[] pem, bool ignoreAsn1DecodingErrors = false, bool hasImplicitTrust = false);
    /// Loads - and optionally validates - a certificate from the given raw DER encoding stored in derBytes . The resulting certificate is then stored within this certificate store. 
    Result loadFromCopyingDerBytes(const ubyte[] derBytes, bool hasImplicitTrust = false);
    ///
    X509CertificateStore opAssign(X509CertificateStore p);
    /// A helper function that combines PemParser and validateChainFromCopyingDerBytes together. Please refer to each of their documentation for any real details. 
    Result validateChainFromPem(const char[] pem, X509CertificateStore.SecurityPolicy policy);
    
}

Documentation

Stores certificates and acts as the main high-level entrypoint for dealing with x.509 certificates.

This type provides a ton of helper functions to make dealing with loading and validation of certificates easier.

Trust anchor selection

When a certificate or certificate chain is verified there must be a "trust anchor" (i.e. a root certificate) that can be used to verify the certificate/chain's signature.

The following options are attempted by this type for identifying the trust anchor of a certificate (or for chains: the first certificate in the chain is used for identifying the anchor).

authorityKeyIdentifier - If the target certificate contains the authorityKeyIdentifier extension, then a lookup for a certficate that has a matching subjectKeyIdentifier extension is performed. If the identifiers match, then the looked up certificate is used as the trust anchor.

Lifetimes

This store is mainly designed for higher level use, and as such it will freely allocate memory.

This store will always create copies of any input data. This means any resulting output will have its lifetime tied to the store itself. So as long as X509CertificateStorestays alive, all of its output will stay alive.

Thread Safety

Currently this store is not thread safe. However once Juptune's event loop has been refactored - ideally with a built-in concept of mutexes - then thread safety will likely be implemented either directly or indirectly.

For now it's recommended to: 1. Perform all loads at program start. 2. ONLY use validation functions from multiple threads. 3. (The above should be thread safe for a while).

Or: 1. Use an external mutex solution - this isn't ideal since it won't integrate properly with Juptune's event loop.

Or: 1. Just make one store per thread.

Aliases

Name Description
__xdtor
foreachCert

Iterates over all certificates found inside of the store, and calls the user provided callback on all of them.

foreachCertGc
validateChainFromCopyingDerBytes

Validates a chain of certificates (or a "chain" with a single certificate) from the given raw DER encoded bytes. These certificates are not loaded into the store, and are immediately freed upon exit of this function.

validateChainFromCopyingDerBytesGC

Functions

Name Description
getBySubjectKeyIdOrNull

Looks up a certificate by its subjectKeyIdentifier, or null if no certificate was found.

loadBundleFromPem

Loads a certificate bundle from the given PEM encoded data.

loadFromCopyingDerBytes

Loads - and optionally validates - a certificate from the given raw DER encoding stored in derBytes. The resulting certificate is then stored within this certificate store.

opAssign
validateChainFromPem

A helper function that combines PemParserand validateChainFromCopyingDerBytestogether. Please refer to each of their documentation for any real details.

Structs

Name Description
Cert

An aggregate type storing a bunch of information about an x.509 certificate.

SecurityPolicy