Node.js x509.ca Property Last Updated : 26 Mar, 2021 Comments Improve Suggest changes Like Article Like Report The x509.ca is an inbuilt application programming interface of class X509Certificate within crypto module which is used to check if this PEM encoded X509 Certificate is a Certificate Authority (ca) certificate or not . Syntax: const x509.ca Parameters: This property does not accept any argument as a parameter. Return Value: This property returns Boolean value true if and only if this PEM encoded X509 Certificate is a Certificate Authority (ca) certificate. How to generate a Public certificate? Public certificate Open notepad and copy-paste the following key and save the file as public-cert.pem -----BEGIN CERTIFICATE----- MIICfzCCAegCCQDxxeXw914Y2DANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMC SU4xEzARBgNVBAgMCldlc3RiZW5nYWwxEDAOBgNVBAcMB0tvbGthdGExFDASBgNV BAoMC1BhbmNvLCBJbmMuMRUwEwYDVQQDDAxSb2hpdCBQcmFzYWQxIDAeBgkqhkiG 9w0BCQEWEXJvZm9mb2ZAZ21haWwuY29tMB4XDTIwMDkwOTA1NTExN1oXDTIwMTAw OTA1NTExN1owgYMxCzAJBgNVBAYTAklOMRMwEQYDVQQIDApXZXN0YmVuZ2FsMRAw DgYDVQQHDAdLb2xrYXRhMRQwEgYDVQQKDAtQYW5jbywgSW5jLjEVMBMGA1UEAwwM Um9oaXQgUHJhc2FkMSAwHgYJKoZIhvcNAQkBFhFyb2ZvZm9mQGdtYWlsLmNvbTCB nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAt/EfcF3FG4TneOBWr4JhOUdyuCXm Dhy5yO3VKtQfPxr+5d0joCSnn/5vYDNSr1MfedZmqVxrXFoMAdPCd71BNmDmeLVi QK61WREtASP0ZhQMoUBT+R3Fpdy0jPS0YoT/fBd96CJCmgsQOS8Tq5IKVeB61MyC kwAQ2Goe0T3sdVkCAwEAATANBgkqhkiG9w0BAQsFAAOBgQATe6ixdAjoV7BSHgRX bXM2+IZLq8kq3s7ck0EZrRVhsivutcaZwDXRCCinB+OlPedbzXwNZGvVX0nwPYHG BfiXwdiuZeVJ88ni6Fm6RhoPtu2QF1UExfBvSXuMBgR+evp+e3QadNpGx6Ppl1aC hWF6W2H9+MAlU7yvtmCQQuZmfQ== -----END CERTIFICATE----- Example 1: index.js // Node.js program to demonstrate the // x509.ca APi // Importing crypto module const {X509Certificate} = require('crypto') // Importing fs module const fs = require('fs') // getting object of a PEM encoded X509 Certificate. const x509 = new X509Certificate(fs.readFileSync('public-cert.pem')); // checking if this is a Certificate Authority (ca) certificate or not // by using x509.ca api const value = x509.ca // display the result if(value) console.log("this is a Certificate Authority (ca) certificate") else console.log("this is not a Certificate Authority (ca) certificate") Run the index.js file using the following command. node index.js Output: this is not a Certificate Authority (ca) certificate Example 2: index.js // Node.js program to demonstrate the // x509.ca APi // Importing crypto module const {X509Certificate} = require('crypto') // Importing fs module const fs = require('fs') // display the result if((new X509Certificate(fs.readFileSync('public-cert.pem'))).ca) console.log("this is a Certificate Authority (ca) certificate") else console.log("this is not a Certificate Authority (ca) certificate") Run the index.js file using the following command. node index.js Output: this is not a Certificate Authority (ca) certificate Reference: https://nodejs.org/dist/latest-v15.x/docs/api/crypto.html#crypto_x509_ca Comment More infoAdvertise with us Next Article Node.js x509.ca Property rohitprasad3 Follow Improve Article Tags : Web Technologies Node.js Node.js-crypto-module Similar Reads Node.js x509.raw Property The x509.raw is an inbuilt application programming interface of class X509Certificate within the crypto module which is used to get a Buffer containing the DER encoding of this certificate. Syntax: const x509.raw Parameters: This property does not accept any arguments as a parameter. Return Value: T 2 min read Node.js x509.issuer Property The x509.issuer is an inbuilt application programming interface of class X509Certificate within the crypto module which is used to get the issuer identification included in this certificate. Syntax: const x509.issuer Parameters: This property does not accept any arguments as a parameter. Return Valu 2 min read Node.js x509.infoAccess Property The x509.infoAccess is an inbuilt application programming interface of class X509Certificate within the crypto module which is used to get the information access content of this certificate. Syntax: const x509.infoAccess Parameters: This property does not accept any arguments as a parameter. Return 2 min read Node.js x509.subject Property The x509.subject is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get complete subject of this certificate. Syntax: const x509.subject Parameters: This function does not accept any arguments as a parameter. Return Value: This function ret 2 min read Node.js x509.validTo Property The x509.validTo is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get the date/time until which this certificate is considered valid. Syntax: const x509.validTo Parameters: This function does not accept any arguments as a parameter. Retur 2 min read Node.js x509.keyUsage Property The x509.keyUsage is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get an array detailing the key usages for this certificate. Syntax: const x509.keyUsage Parameters: This property does not accept any arguments as a parameter. Return Valu 2 min read Node.js x509.fingerprint Property The x509.fingerprint is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get the SHA-1 fingerprint of this certificate. Syntax: const x509.fingerprint Parameters: This property does not accept any arguments as a parameter. Return Value: This 2 min read Node.js x509.issuerCertificate Property The x509.issuerCertificate is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get the issuer certificate or undefined if the issuer certificate is not available. Syntax: const x509.issuerCertificate Parameters: This property does not accept 2 min read Node.js x509.publicKey Property The x509.publicKey is an inbuilt application programming interface of class X509Certificate within the crypto module which is used to the public key of this certificate. Syntax: const x509.publicKey Parameters: This API does not accept any arguments as a parameter. Return Value: This API returns the 2 min read Node.js x509.validFrom Property The x509.validFrom is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get the date/time from which this certificate is considered valid. Syntax: const x509.validFrom Parameters: This function does not accept any arguments as a parameter. Re 2 min read Like