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

Aliases x509FromPem

1
2
3
module juptune.data.x509.asn1convert;

alias x509FromPem = __MARMOS_BUG__;

Documentation

Parses all certificates from the given PEM-encoded string, and passes them to the user provided callback.

Notes

The user code is completely in charge of managing the memory used by this function, via teh onPutBytesand onFinishBytescallbacks.

The result of onFinishBytesMUST stay valid until onCertificateis called for the certificate represented by those "finished bytes". In other words, once onCertificateis called, the underlying bytes can be immediately freed if the user code wishes, though that will also invalidate the Certificateand X509Certificatethat was parsed from it.

If the user code needs to preserve either form of the parse certificate, then it MUST keep the underlying "finished bytes" for it alive as well, as their lifetimes are all tied together.

Callback Examples

` import std.array : Appender;

Appender!(ubyte[]) buffer; X509Certificate[] certs;

x509FromPemGC( getPemCertificateSomehow(), onPutBytes: (scope bytes) { buffer.put(bytes); return Result.noError; }, onFinishBytes: (scope out bytes) { bytes = buffer.data.idup; buffer.clear(); return Result.noError; }, onCertificate: (asn1Cert, x509Cert) { certs ~= x509Cert; return Result.noError; } // Safe since we copied the underlying bytes ); `

Params

Throws

Anything that onPutBytescan throw.

Anything that onFinishBytescan throw.

Anything that onCertificatecan throw.

Anything that PemParser.parseNextInfercan throw.

Anything that x509FromDerBytescan throw.

X509Error.wrongPemLabelif any PEM label is not "CERTIFICATE" (TODO: Some PEMs also have a PRIVATE KEY label, need to figure out how to best handle that case).

Returns

A result indicating if an error occurred or not.