X509 / Certificate
This package also exposes a couple of helpers related to X509/SPKAC parsing:
CertificateX509CertificateExtensions
Import:
import { Certificate, X509CertificateExtensions } from "@tsonic/nodejs/index.js";
Example:
import { console, X509CertificateExtensions } from "@tsonic/nodejs/index.js";
export function main(): void {
// See the type signatures for details (expects certificate bytes or a PEM string).
console.log(typeof X509CertificateExtensions.parseCertificate);
}
API Reference
Certificate
export declare const Certificate: {
exportChallenge(spkac: byte[]): byte[];
exportChallenge(spkac: string): byte[];
exportPublicKey(spkac: byte[]): byte[];
exportPublicKey(spkac: string): byte[];
verifySpkac(spkac: byte[]): boolean;
verifySpkac(spkac: string): boolean;
};
X509CertificateExtensions
export declare const X509CertificateExtensions: {
parseCertificate(certificate: byte[]): X509CertificateInfo;
parseCertificate(certificate: string): X509CertificateInfo;
};
X509CertificateInfo
export interface X509CertificateInfo {
readonly fingerprint: string;
readonly fingerprint256: string;
readonly fingerprint512: string;
readonly issuer: string;
readonly publicKey: byte[];
readonly raw: byte[];
readonly serialNumber: string;
readonly subject: string;
readonly validFrom: DateTime;
readonly validTo: DateTime;
checkEmail(email: string): string | undefined;
checkHost(hostname: string): string | undefined;
checkIP(ip: string): string | undefined;
checkIssued(otherCert: X509CertificateInfo): string | undefined;
toPEM(): string;
toString(): string;
verify(issuerCert: X509CertificateInfo): boolean;
}
export const X509CertificateInfo: {
new(): X509CertificateInfo;
};