Certificate Authority (CA)
Certificate validation
Install a self-signed CA certificate
-
Windows 10
certutil –addstore -enterprise –f "Root" <pem-file>
- Open
Run
dialog, typecertmgr.msc
- The imported certificate will show up under
Trusted Root Certification Authorities - Certificates
- Open
-
Ubuntu
Add
sudo mkdir /usr/local/share/ca-certificates/extra sudo cp CA.cert.pem /usr/local/share/ca-certificates/extra/CA.cert.crt sudo update-ca-certificates
Remove
sudo rm /usr/local/share/ca-certificates/extra/CA.cert.crt sudo update-ca-certificates # This will remove the symlink under /etc/ssl/certs
-
Fedora
Add
sudo trust anchor "$CA_certificate.pem" # or manually sudo cp "$CA.cert.pem" /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust
Remove
sudo trust anchor --remove path.to/certificate.crt # or manually sudo rm /etc/pki/ca-trust/source/anchors/CA.cert.pem sudo update-ca-trust
-
Application
-
Java
- Use
keytool
to importCA
certificates
into$JAVA_HOME/lib/security/cacerts
- Use
-
Nodejs
- Use environment variable
NODE_EXTRA_CA_CERTS
for customCA
certificates: NODE_EXTRA_CA_CERTS=file (opens in a new tab)
- Use environment variable
-
Docker
-
DNS
-
The certificate is valid only if the request hostname matches the certificate
Common Name (CN)
orSubject Alternative Names
-
Multi-Domain (MD)
orSubject Alternative Names (SAN)
SSL CertificatesAlso commonly referred to as SAN certificates, multi-domain SSL allow a single certificate to secure multiple domains, including subdomains of a single main domain name or entirely different domain names. One of these can secure up to 250 unique domains with a single solution. They provide a convenient option for organizations that own a lot of domains and are looking for a simplified way to secure them through a single solution rather than purchasing an individual certificate for each. Multi-domain SSL certificates are available in DV, OV, and EV validation options.
-
Wildcard
SSL CertificatesThe Wildcard option is used to secure the main domain and an unlimited number of subdomains under the main domain. For example, www.yourwebsite.com (opens in a new tab), login.yourwebsite.com, mail.yourwebsite.com, etc. Wildcard certificates offer full encryption for the subdomains, making them an affordable and effective solution for most websites. They are available in DV and OV validation options.
Private key
PKCS#8
- PEM base64-encoded format
CSR
CSR
is generated and sent to aCA
to request the issuance of aCA
-signedSSL
certificate.CSR
contains information for identification purposes, which will be stored into theCA
-signed certificate along withCA
's public key.- You can use
OpenSSL
to generate a new private key and aCSR
, or generate aCSR
from an existing private key. - Format:
PKCS#10
- Wikipedia - CSR (opens in a new tab)
Serial number
- A number that uniquely identifies the certificate and is issued by the
CA
.
Thumbprint / Fingerprint
-
A certificate's fingerprint is the unique identifier of the certificate. It is the hash value of the entire certificate in
DER
format. A certificate could have multiple fingerprints computed by different hash functions such asSHA-256
. Certificate details in web browser include fingerprints. -
sha256sum / sha1sum $crt.der | tr '[:lower:]' '[:upper:]'
should get the same hash value as:
openssl s_client -connect <host>:<port> 2>/dev/null | openssl x509 -noout -fingerprint -sha256/-sha1
Certificate Formats
-
Base64 ASCII
-
PEM
-
Start with
-----BEGIN CERTIFICATE-----
and end with-----END CERTIFICATE-----
The
header
andfooter
are fixed strings, and must not be changed. -
In the middle is actually
Base64
encodedDER
format. -
Multiple
PEM
files can be concatenated into onePEM
file. -
PKCS#7
(container format)
-
-
-
Binary encoding
-
DER
PKCS#12
(container format)
-
-
Resources
Key usage
-
The key usage extension defines the purpose (e.g., encipherment, signature, certificate signing) of the key contained in the certificate. The usage restriction might be employed when a key that could be used for more than one operation is to be restricted.
-
Resources
Java (JSSE
)
-
A
KeyStore
typically holds onto certificates that identify us, therefore typically consisting ofcertificates
for servers. TheKeyStore
fails to work withJSSE
without a password. -
A
TrustStore
holds certificates that identify others, therefore typically consisting ofCA certificates
(akaroot certificates
). -
Java
only supportsKeyStore
format ofJKS
orPKCS#12
(Java SE 9+
, JEP 229 (opens in a new tab)), the latter is preferred as it's an industry standard. -
To import
CA
certificate, onlyDER
format can be used. -
Private
CA
Certificate for local Java developmentRefer to cheatsheet for details
-
Steps
-
Generate a
private key
andCA certificate
pair -
Import the generated
CA certificate
into OSCA
trust store -
Import domain private key and certificate into a
JKS
/PKCS#12
KeyStore
-
Install and configure your
SSL/TLS
certificate
inSpring Boot
application config# Spring Boot 2.4.4 server.port=8443 server.ssl.enabled=true server.ssl.key-store=<keystore.jks> server.ssl.key-store-password=<keystore-password> server.ssl.key-store-type=JKS server.ssl.key-alias=<key-alias>
-
If browser uses a custom trust store, import your
CA
certificate
into it.
-
-
Windows 10
Firstly generate a
PEM
certificate usingOpenSSL
, the certificate format can't be directly imported viaWindows MMC
GUI, therefore using the command line (opens in a new tab):certutil –addstore -enterprise –f "Root" <pem-file>
. This will import certificate toroot
. -
Resources
- HTTPS using Self-Signed Certificate in Spring Boot (opens in a new tab)
- How to Create Your Own SSL Certificate Authority for Local HTTPS Development (Tested using this tutorial to generate root certificate on Win 10) (opens in a new tab)
- How to get HTTPS working on your local development environment in 5 minutes (opens in a new tab)
- Be Your Own Certificate Authority (opens in a new tab)
- Baeldung - Creating a Self-Signed Certificate With OpenSSL (opens in a new tab)
- GitHub Gist - How to setup your own CA with OpenSSL (opens in a new tab)
-
-
Resources
ACME (Automatic Certificate Management Environment)
Certbot
$ sudo certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: crystallover.com.au
2: www.crystallover.com.au
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Requesting a certificate for crystallover.com.au and www.crystallover.com.au
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/crystallover.com.au/fullchain.pem
Key is saved at: /etc/letsencrypt/live/crystallover.com.au/privkey.pem
This certificate expires on 2024-03-13.
These files will be updated when the certificate renews.
Deploying certificate
Successfully deployed certificate for crystallover.com.au to /etc/nginx/conf.d/crystallover.conf
Successfully deployed certificate for www.crystallover.com.au to /etc/nginx/conf.d/crystallover.conf
Congratulations! You have successfully enabled HTTPS on https://crystallover.com.au and https://www.crystallover.com.au
NEXT STEPS:
- The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -