A certificate is for verifying the identity of any entities involving in a communication flow. The entities can be server / user / client.
Normally, a certificate contains:
There are 2 types of certificate in terms of Issuer :
In SSL communications, the server’s SSL Certificate contains an asymmetric public and private key pair. The session key that the server and the browser create during the SSL Handshake is symmetric. This is explained further in the diagram below.
Don't confuse client certificates with server certificates. Both are digital certificates that involve client and server applications but they're two different things.
Server must enable client certificate authentication.
NOTE:
To strengthen user authentication by implementing in different ways a.k.a. factors:
Combining 2 or multi factors of authentication makes it significantly more difficult for an attacker to succeed.
0. Private key is NOT solely for decrypting. Public key is NOT solely for encrypting. If one key signs, the other decrypts.
1. PEM: Privacy-Enhanced mail just means the file contains a base64-encoded bit of data.
Although PEM is widely used for certificates and many PEM files are certificates, be aware PEM is used for many other things as well, such as merely Private key or Public key.
It can have a variety of extensions (.pem, .key, .cer, .cert, more)
Don't assume a PEM file is a certificate; instead check the label in header line.
Format:
The label determines the type of message encoded. Common labels include "CERTIFICATE", "CERTIFICATE REQUEST", "PRIVATE KEY" and "X509 CRL"
example-----BEGIN CERTIFICATE-----MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQLExxHbnVUTFMgY2VydGlmaWNhdGUgYXV0aG9yaXR5MQ8wDQYDVQQIEwZMZXV2ZW4xJTAjBgNVBAMTHEdudVRMUyBjZXJ0aWZpY2F0ZSBhdXRob3JpdHkwHhcNMTEwNTIzMjAzODIxWhcNMTIxMjIyMDc0MTUxWjB9MQswCQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQLExxHbnVUTFMgY2VydGlmaWNhdGUgYXV0aG9yaXR5MQ8wDQYDVQQIEwZMZXV2ZW4xJTAjBgNVBAMTHEdudVRMUyBjZXJ0aWZpY2F0ZSBhdXRob3JpdHkwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARS2I0jiuNn14Y2sSALCX3IybqiIJUvxUpj+oNfzngvj/Niyv2394BWnW4XuQ4RTEiywK87WRcWMGgJB5kX/t2no0MwQTAPBgNVHRMBAf8EBTADAQH/MA8GA1UdDwEB/wQFAwMHBgAwHQYDVR0OBBYEFPC0gf6YEr+1KLlkQAPLzB9mTigDMAoGCCqGSM49BAMCA0gAMEUCIDGuwD1KPyG+hRf88MeyMQcqOFZD0TbVleF+UsAGQ4enAiEAl4wOuDwKQa+upc8GftXE2C//4mKANBC6It01gUaTIpo=-----END CERTIFICATE-----2. X509: is a standard defining the format of certificate.
CertificateSerial NumberSignature Algorithm IDIssuer NameValidity period: not before, not afterSubject nameSubject Public Key InfoPublic Key AlgorithmSubject Public Key...Certificate Signature AlgorithmCertificate Signature3. CER, CRT are both EXTENSIONS of a file containing X509 Certificate. In general, they are the CERTIFICATES
(Just like .mp4 and .avi, they are two different extensions which contain video data.)
4. DER and PEM: they are two different Encodings for certificate file content
5. pfx, p12: bundle a private key with its public corresponding X.509 certificate.
It can contain a chain of "intermediate" certificate to form a better trust chain.
This is a passworded container format that contains both public and private certificate pairs. Unlike .pem files, this container is fully encrypted. Openssl can turn this into a .pem file with both public and private keys
6. OpenSSL and Keytool:
certlm.mscTo list all key stored in cacert file (which is a keystore .jks):
keytool -list -keystore ${cacertsPath} -v where ${cacertsPath} is path to cacerts file (JAVA_HOME---> JRE -->lib---> security--> cacerts) -v for all details of each entryeg: keytool -list -keystore /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/jre/lib/security/cacerts -v7. The basics command line steps to generate a private and public key using OpenSSL are as follow
openssl genrsa -out private.key 1024openssl req -new -x509 -key private.key -out publickey.cer -days 365openssl pkcs12 -export -out public_privatekey.pfx -inkey private.key -in publickey.cerStep 1 – generates a private key
Step 2 – creates a X509 certificate (.cer file) containing your public key which you upload when registering your private application (or upgrading to a partner application).
Step 3 – Export your x509 certificate and private key to a pfx file. If your chosen wrapper library uses the .pem file to sign requests then this step is not required.