declare namespace jsrsasign { interface ExtensionParameter { [key: string]: any; extname: string; critical: boolean; names: string[]; kid: { [key: string]: any; }; array: any[]; } interface X500Name { array: Array>; str: string; } type GeneralName = | { rfc822: string; } | { dns: string; } | { uri: string; } | { ip: string; } | { dn: X500Name; } | { other: ASN1HEXParseResult; } | undefined; interface DistributionPointName { full?: GeneralName[]; } type IdentityArray = Array<[{ type: string; value: string; ds: string }]>; interface X509Extension { oid: string; critical: boolean; vidx: number; } interface IdentityResponse { array: IdentityArray; str: string; } interface CertificateTBSParams { version?: number; // this can be omitted, the default is 3. serial: Hex | { int: number } | { bigint: number } | number; // DERInteger parameter issuer: { array: IdentityArray } | { str: string } | { array: IdentityArray; str: string }; // X500Name parameter sigalg?: string; notbefore: string; // string, passed to Time notafter: string; // string, passed to Time subject: { array: IdentityArray } | { str: string } | { array: IdentityArray; str: string }; // X500Name parameter sbjpubkey: | RSAKey | ECCPrivateKey | KJUR.crypto.ECDSA | KJUR.crypto.DSA | KJUR.jws.JWS.JsonWebKey | { n: string; e: string } | string; // KEYUTIL.getKey pubkey parameter ext: Array<{ extname: string; [x: string]: any }>; } interface Hex { hex: string; } interface AuthorityKeyIdentifierResult { kid: Hex; issuer?: Hex; sn?: Hex; critical?: boolean; } interface PublicKeyInfoPropOfCertPEMResult { /** hexadecimal string of OID of asymmetric key algorithm */ algoid: string; /** hexadecimal string of OID of ECC curve name or null */ algparam: string | null; /** hexadecimal string of key in the certificate */ keyhex: string; } interface DistributionPoint { dpname?: DistributionPointName; } interface DisplayText { type: string; str: string; } interface UserNotice { exptext?: DisplayText; } type PolicyQualifierInfo = | { cps: string; } | { unotice: UserNotice; } | {}; interface PolicyInformation { policyoid: string; array?: PolicyQualifierInfo[]; } type GeneralSubtree = (GeneralName & { min: number }) | (GeneralName & { max: number }); interface ExtSubjectKeyIdentifier { extname: "subjectKeyIdentifier"; kid: Hex; critical?: boolean; } interface ExtKeyUsage { extname: "keyUsage"; critical?: boolean; names: string[]; } interface ExtSubjectAltName { extname: "subjectAltName"; array: GeneralName[]; critical?: boolean; } interface ExtIssuerAltName { extname: "issuerAltName"; array: GeneralName[]; } interface ExtBasicConstraints { extname: "basicConstraints"; critical?: boolean; cA?: boolean; pathLen?: number; } type ExtNameConstraints = | { extname: "nameConstraints"; critical?: boolean; permit: GeneralSubtree[] } | { extname: "nameConstraints"; critical?: boolean; exclude: GeneralSubtree[] }; interface ExtCRLDistributionPoints { extname: "cRLDistributionPoints"; array: DistributionPoint[]; critical?: boolean; } interface ExtCertificatePolicies { extname: "certificatePolicies"; array: PolicyInformation[]; critical?: boolean; } interface ExtAuthorityKeyIdentifier { extname: "authorityKeyIdentifier"; kid: Hex; issuer?: Hex; sn?: Hex; critical?: boolean; } interface ExtExtKeyUsage { extname: "extKeyUsage"; array: string[]; critical?: boolean; } interface ExtAuthorityInfoAccess { extname: "authorityInfoAccess"; critical?: boolean; array: Array< ( | { ocsp: string; } | { caissuer: string; } ) >; } interface ExtCRLNumber { extname: "cRLNumber"; critical?: boolean; num?: { hex: string }; } interface ExtCRLReason { extname: "cRLReason"; critical?: boolean; code?: number; } interface ExtOcspNonce { extname: "ocspNonce"; critical?: boolean; hex: string; } interface ExtOcspNoCheck { extname: "ocspNoCheck"; critical?: boolean; } interface ExtAdobeTimeStamp { extname: "adobeTimeStamp"; critical?: boolean; uri?: string; reqauth?: boolean; } type ExtParam = | { [key: string]: any; extname: string; extn: string; critical?: boolean; code?: number; } | ExtSubjectKeyIdentifier | ExtKeyUsage | ExtSubjectAltName | ExtIssuerAltName | ExtBasicConstraints | ExtNameConstraints | ExtCRLDistributionPoints | ExtCertificatePolicies | ExtAuthorityKeyIdentifier | ExtExtKeyUsage | ExtAuthorityInfoAccess | ExtCRLNumber | ExtCRLReason | ExtOcspNonce | ExtOcspNoCheck | ExtAdobeTimeStamp; interface AIAInfo { caissuer: string[]; ocsp: string[]; } interface UserNotice { exptext?: DisplayText; } /** * hexadecimal X.509 certificate ASN.1 parser class.
* property String hex hexacedimal string for X.509 certificate. * property Number version format version (1: X509v1, 3: X509v3, otherwise: unknown) since jsrsasign 7.1.4 * property Array aExtInfo (DEPRECATED) array of parameters for extensions * @author Kenji Urushima * @version 1.0.1 (08 May 2012) * @see 'jsrsasign'(RSA Sign JavaScript Library) home page https://kjur.github.io/jsrsasign/ * @description * X509 class provides following functionality: * * * */ class X509 { /** * hexacedimal string for X.509 certificate. */ hex: string; /** * format version (1: X509v1, 3: X509v3, otherwise: unknown) since jsrsasign 7.1.4 */ static readonly version: number; foffset: number; /** * (DEPRECATED) array of parameters for extensions */ aExtInfo: X509Extension[]; constructor(params?: string); /** * get format version (X.509v1 or v3 certificate)
* @return Number 1 for X509v1, 3 for X509v3, otherwise 0 * @since jsrsasign 7.1.14 x509 1.1.13 * @description * This method returns a format version of X.509 certificate. * It returns 1 for X.509v1 certificate and 3 for v3 certificate. * Otherwise returns 0. * This method will be automatically called in * {@link X509#readCertPEM}. After then, you can use * {@link X509.version} parameter. * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * version = x.getVersion(); // 1 or 3 * sn = x.getSerialNumberHex(); // return string like "01ad..." */ getVersion(): number; /** * get hexadecimal string of serialNumber field of certificate.
* @return String hexadecimal string of certificate serial number * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var sn = x.getSerialNumberHex(); // return string like "01ad..." */ getSerialNumberHex(): string; /** * get signature algorithm name in basic field * @return String signature algorithm name (ex. SHA1withRSA, SHA256withECDSA, SHA512withRSAandMGF1) * @since x509 1.1.8 * @see X509#getAlgorithmIdentifierName * @description * This method will get a name of signature algorithm in * basic field of certificate. *
* NOTE: From jsrsasign 8.0.21, RSA-PSS certificate is also supported. * For supported RSA-PSS algorithm name and PSS parameters, * see {@link X509#getSignatureAlgorithmField}. * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * algName = x.getSignatureAlgorithmField(); */ getSignatureAlgorithmField(): string; /** * get algorithm name name of AlgorithmIdentifier ASN.1 structure * @param hTLV hexadecimal string of AlgorithmIdentifier * @return String algorithm name (ex. SHA1withRSA, SHA256withECDSA, SHA512withRSAandMGF1, SHA1) * @since jsrsasign 9.0.0 x509 2.0.0 * @description * This method will get a name of AlgorithmIdentifier. *
* @example * var x = new X509(); * algName = x.getAlgorithmIdentifierName("30..."); */ getAlgorithmIdentifierName(hTLV: string): string; /** * get JSON object of issuer field
* @return Array JSON object of issuer field * @since jsrsasign 9.0.0 x509 2.0.0 * @see X509#getX500Name * @description * @example * var x = new X509(sCertPEM); * x.getIssuer() → * { array: [[{type:'C',value:'JP',ds:'prn'}],...], * str: "/C=JP/..." } */ getIssuer(): IdentityResponse; /** * get hexadecimal string of issuer field TLV of certificate.
* @return String hexadecial string of issuer DN ASN.1 * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var issuer = x.getIssuerHex(); // return string like "3013..." */ getIssuerHex(): string; /** * get string of issuer field of certificate.
* @return String issuer DN string * @see X509#getIssuer * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var dn1 = x.getIssuerString(); // return string like "/C=US/O=TEST" * var dn2 = KJUR.asn1.x509.X500Name.compatToLDAP(dn1); // returns "O=TEST, C=US" */ getIssuerString(): string; /** * get JSON object of subject field
* name getSubject * memberOf X509# * * @return Array JSON object of subject field * @since jsrsasign 9.0.0 x509 2.0.0 * @see X509#getX500Name * @description * @example * var x = new X509(sCertPEM); * x.getSubject() → * { array: [[{type:'C',value:'JP',ds:'prn'}],...], * str: "/C=JP/..." } */ getSubject(): IdentityResponse; /** * get hexadecimal string of subject field of certificate.
* name getSubjectHex * memberOf X509# * * @return String hexadecial string of subject DN ASN.1 * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var subject = x.getSubjectHex(); // return string like "3013..." */ getSubjectHex(): string; /** * get string of subject field of certificate.
* name getSubjectString * memberOf X509# * * @return String subject DN string * @see X509#getSubject * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var dn1 = x.getSubjectString(); // return string like "/C=US/O=TEST" * var dn2 = KJUR.asn1.x509.X500Name.compatToLDAP(dn1); // returns "O=TEST, C=US" */ getSubjectString(): string; /** * get notBefore field string of certificate.
* name getNotBefore * memberOf X509# * * @return String not before time value (ex. "151231235959Z") * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var notBefore = x.getNotBefore(); // return string like "151231235959Z" */ getNotBefore(): string; /** * get notAfter field string of certificate.
* name getNotAfter * memberOf X509# * * @return String not after time value (ex. "151231235959Z") * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * var notAfter = x.getNotAfter(); // return string like "151231235959Z" */ getNotAfter(): string; /** * get a hexadecimal string of subjectPublicKeyInfo field.
* name getPublicKeyHex * memberOf X509# * * @return String ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field * @since jsrsasign 7.1.4 x509 1.1.13 * @deprecated since jsrsasign 10.5.7 x509 2.0.13. Please use {@link X509#getSPKI} instead. * * @example * x = new X509(sCertPEM); * hSPKI = x.getPublicKeyHex(); // return string like "30820122..." */ getPublicKeyHex(): string; /** * get ASN.1 TLV hexadecimal string of subjectPublicKeyInfo field.
* name getSPKI * memberOf X509# * * @return string ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field * @since jsrsasign 10.5.8 x509 2.0.13 * @see X509#getPublicKeyHex * @see X509#getSPKIValue * * @description * Get a hexadecimal string of SubjectPublicKeyInfo ASN.1 TLV of the certificate.
*
         * SubjectPublicKeyInfo  ::=  SEQUENCE  {
         *    algorithm         AlgorithmIdentifier,
         *    subjectPublicKey  BIT STRING  }
         * 
* * @example * x = new X509(sCertPEM); * hSPKI = x.getSPKI(); // return string like "30820122..." */ getSPKI(): string; /** * get hexadecimal string of subjectPublicKey of subjectPublicKeyInfo field.
* name getSPKIValue * memberOf X509# * * @return string ASN.1 hexadecimal string of subjectPublicKey * @since jsrsasign 10.5.8 x509 2.0.13 * @see X509#getSPKI * * @description * Get a hexadecimal string of subjectPublicKey ASN.1 value of SubjectPublicKeyInfo * of the certificate without unusedbit "00". * The "subjectPublicKey" is encapsulated by BIT STRING. * This method returns BIT STRING value without unusedbits. *
*
         * SubjectPublicKeyInfo  ::=  SEQUENCE  {
         *    algorithm         AlgorithmIdentifier,
         *    subjectPublicKey  BIT STRING  }
         * 
* * @example * x = new X509(sCertPEM); * hSPKIValue = x.getSPKIValue(); // without BIT STRING Encapusulation. */ getSPKIValue(): string; /** * get a string index of subjectPublicKeyInfo field for hexadecimal string certificate.
* name getPublicKeyIdx * memberOf X509# * * @return Number string index of subjectPublicKeyInfo field for hexadecimal string certificate. * @since jsrsasign 7.1.4 x509 1.1.13 * @example * x = new X509(); * x.readCertPEM(sCertPEM); * idx = x.getPublicKeyIdx(); // return string index in x.hex parameter */ getPublicKeyIdx(): number; /** * get a string index of contents of subjectPublicKeyInfo BITSTRING value from hexadecimal certificate
* name getPublicKeyContentIdx * memberOf X509# * * Integer string index of key contents * @since jsrsasign 8.0.0 x509 1.2.0 * @example * x = new X509(); * x.readCertPEM(sCertPEM); * idx = x.getPublicKeyContentIdx(); // return string index in x.hex parameter */ // NOTE: Without BITSTRING encapsulation. getPublicKeyContentIdx(): number; /** * get a RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field.
* name getPublicKey * memberOf X509# * * @return Object RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field * @since jsrsasign 7.1.4 x509 1.1.13 * @example * x = new X509(); * x.readCertPEM(sCertPEM); * pubkey= x.getPublicKey(); */ getPublicKey(): RSAKey | KJUR.crypto.DSA | KJUR.crypto.ECDSA; /** * get signature algorithm name from hexadecimal certificate data * name getSignatureAlgorithmName * memberOf X509# * * @return String signature algorithm name (ex. SHA1withRSA, SHA256withECDSA) * @since jsrsasign 7.2.0 x509 1.1.14 * @see X509#getAlgorithmIdentifierName * @description * This method will get signature algorithm name of certificate: * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * x.getSignatureAlgorithmName() → "SHA256withRSA" */ getSignatureAlgorithmName(): string; /** * get signature value as hexadecimal string
* name getSignatureValueHex * memberOf X509# * * @return String signature value hexadecimal string without BitString unused bits * @since jsrsasign 7.2.0 x509 1.1.14 * * @description * This method will get signature value of certificate: * * @example * var x = new X509(); * x.readCertPEM(sCertPEM); * x.getSignatureValueHex() &rarr "8a4c47913..." */ getSignatureValueHex(): string; /** * verifies signature value by public key
* name verifySignature * memberOf X509# * * @param pubKey public key object * @return Boolean true if signature value is valid otherwise false * @since jsrsasign 7.2.0 x509 1.1.14 * * @description * This method verifies signature value of hexadecimal string of * X.509 certificate by specified public key object. * The signature algorithm used to verify will refer * signatureAlgorithm field. (See {@link X509#getSignatureAlgorithmField}) * RSA-PSS signature algorithms (SHA{,256,384,512}withRSAandMGF1) * are available. * * @example * pubKey = KEYUTIL.getKey(pemPublicKey); // or certificate * x = new X509(); * x.readCertPEM(pemCert); * x.verifySignature(pubKey) → true, false or raising exception */ verifySignature(pubKey: string | RSAKey | KJUR.crypto.DSA | KJUR.crypto.ECDSA | ECCPrivateKey): boolean; /** * set array of X.509v3 and CSR extesion information such as extension OID, criticality and value index. (DEPRECATED)
* name parseExt * memberOf X509# * * @param hCSR - PEM string of certificate signing requrest(CSR) (OPTION) * @since jsrsasign 7.2.0 x509 1.1.14 * @deprecated jsrsasign 9.1.1 x509 2.0.1 * * @description * This method will set an array of X.509v3 extension information having * following parameters: *