Create a suitable folder or navigate to a suitable file path and clone this gist
git clone https://gist.github.com/abuxton/4f43ef8731fa00768440aa9cd8dbee89 foldername
cd foldername
Open ssl.conf
in a text editor.
Edit the domain(s) listed under the [alt_names]
section so that they match the local domain name you want to use for your project, e.g.
DNS.1 = my-project.dev
Additional FQDNs can be added if required:
DNS.1 = my-project.dev
DNS.2 = www.my-project.dev
DNS.3 = fr.my-project.dev
Create a directory for your project, e.g. my_project
and save ssl.conf
inside it.
Open Terminal and navigate to 'my_project':
cd my_project
Generate a private key:
openssl genrsa -out private.key 4096
Generate a Certificate Signing Request
openssl req -new \
-out private.csr \
-key private.key \
-config ssl.conf
(You will be asked a series of questions about your certificate. Answer however you like, but for 'Common name' enter the name of your project, e.g. my_project
)
Now check the CSR:
openssl req -text -noout -in private.csr
You should see this:
X509v3 Subject Alternative Name: DNS:my-project.site
and
Signature Algorithm: sha256WithRSAEncryption
Generate the certificate
openssl x509 -req \
-nodes \
-days 365 \
-in private.csr \
-signkey private.key \
-out private.crt \
-extensions req_ext \
-extfile ssl.conf
Add the certificate to keychain and trust it from command line:
# darwin osx
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain private.crt
# ubuntu
$ sudo cp local-ca.crt /usr/local/share/ca-certificates
$ sudo update-ca-certificates
If you're using OSX double click on the certificate file private.crt
to open Keychain Access. Your project name my_project
will be listed under the login keychain. Double click it and select 'Always trust' under the 'Trust' section.)
If you are using MAMP Pro, add (or edit) a host with the server name you listed under the [alt_names]
section of your ssl.conf. On the SSL tab select the Certificate file and Certificate key that you just generated.
Save changes and restart Apache.
- https://blogs.keysight.com/blogs/tech/nwvs.entry.html/2022/03/10/hostname_san-dwichintlscerts-YwUg.html
- https://www.phildev.net/ssl/opensslconf.html
- https://ubuntu.com/server/docs/security-trust-store
- openssl_chatesheet.md
The common name can only contain up to one entry: either a wildcard or non-wildcard name. It’s not possible to specify a list of names covered by an SSL certificate in the common name field.
The Subject Alternative Name extension (also called Subject Alternate Name or SAN) was introduced to solve this limitation. The SAN allows issuance of multi-name SSL certificates.
The ability to directly specify the content of a certificate SAN depends on the Certificate Authority and the specific product. Most certificate authorities have historically marketed multi-domain SSL certificates as a separate product. They’re generally charged at a higher rate than a standard single-name certificate.
On the technical side, the SAN extension was introduced to integrate the common name. Since HTTPS was first introduced in 2000 (and defined by the RFC 2818), the use of the commonName field has been considered deprecated, because it’s ambiguous and untyped.
The CA/Browser Forum has since mandated that the SAN would also include any value present in the common name, effectively making the SAN the only required reference for a certificate match with the server name. The notion of the common name survives mostly as a legacy of the past. There are active discussions to remove its use from most browsers and interfaces.