ubuntu:certificates:create_a_self-signed_certificate
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:certificates:create_a_self-signed_certificate [2023/06/09 16:07] – peter | ubuntu:certificates:create_a_self-signed_certificate [2023/06/09 16:26] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Ubuntu - Certificates - Create a self-signed certificate ====== | ====== Ubuntu - Certificates - Create a self-signed certificate ====== | ||
+ | |||
+ | A self-signed certificate made in this way is sufficient for testing, but should not be used in a production environment. | ||
+ | |||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * Many clients require that the certificate presented by the server be a user (also called “leaf” or “site”) certificate, | ||
+ | * In this situation, the self-signed certificate must be installed on the client host as a trusted root certification authority (CA), and the certificate used must be a user certificate signed with that self-signed certificate. | ||
+ | |||
+ | * For information on creating self-signed CA certificates and using them to sign user certificates, | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Prerequisites ===== | ||
+ | |||
+ | Ensure that openssl is installed. | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt install openssl | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | <code bash> | ||
+ | man openssl | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ---- | ||
===== Create a self-signed certificate ===== | ===== Create a self-signed certificate ===== | ||
Line 8: | Line 42: | ||
openssl req -x509 -newkey rsa:2048 -keyout file1.key -out file2.crt -days 9999 -nodes | openssl req -x509 -newkey rsa:2048 -keyout file1.key -out file2.crt -days 9999 -nodes | ||
</ | </ | ||
+ | |||
+ | or | ||
+ | |||
+ | <code bash> | ||
+ | openssl req -new -x509 -days 9999 -nodes -out file1.pem -keyout file2.key | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | |||
+ | * You could, in **/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | This will prompt with a number of questions. | ||
+ | |||
+ | < | ||
+ | Generating a 2048 bit RSA private key | ||
+ | ...........................+++ | ||
+ | ...........................................................................+++ | ||
+ | writing new private key to ' | ||
+ | ----- | ||
+ | You are about to be asked to enter information that will be incorporated | ||
+ | into your certificate request. | ||
+ | What you are about to enter is what is called a Distinguished Name or a DN. | ||
+ | There are quite a few fields but you can leave some blank | ||
+ | For some fields there will be a default value, | ||
+ | If you enter ' | ||
+ | ----- | ||
+ | Country Name (2 letter code) [AU]:JE | ||
+ | State or Province Name (full name) [Some-State]: | ||
+ | Locality Name (eg, city) []:St. Helier | ||
+ | Organization Name (eg, company) [Internet Widgits Pty Ltd]: | ||
+ | Organizational Unit Name (eg, section) []: | ||
+ | Common Name (e.g. server FQDN or YOUR name) []: | ||
+ | Email Address []: | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
<WRAP info> | <WRAP info> | ||
Line 26: | Line 101: | ||
<WRAP important> | <WRAP important> | ||
- | <color red> | + | <color red> |
- | </ | + | |
- | A self-signed certificate made in this way is sufficient for testing, and may be adequate for all your requirements if you are mainly interested in encrypting transfers, and not in secure identification. | + | * If the system uses unsigned time_t (most do) and is 32-bit, then the above command might produce a date in the past. |
+ | * Think carefully about the lifetime of the systems | ||
+ | * Reducing the duration is the most likely choice, but the inexorable progression of time takes us steadily towards an era where this will not be a sensible resolution. | ||
+ | </ | ||
- | However, many clients require that the certificate presented by the server be a user (also called “leaf” or “site”) certificate, | ||
- | For information on creating self-signed CA certificates and using them to sign user certificates, | ||
---- | ---- | ||
===== Broken down ===== | ===== Broken down ===== | ||
+ | |||
+ | The same code as above, but split into separate commands: | ||
<code bash> | <code bash> | ||
Line 56: | Line 133: | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Set Permissions for the certificate files ===== | ||
+ | |||
+ | <code bash> | ||
+ | chmod 600 file1* | ||
+ | chmod 600 file2* | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== References ===== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | http:// | ||
+ | |||
+ | http:// | ||
+ | |||
+ | http:// |
ubuntu/certificates/create_a_self-signed_certificate.1686326855.txt.gz · Last modified: 2023/06/09 16:07 by peter