Configure CA environment
# mkdir -p /etc/pki/LDAP_CA/private# touch /etc/pki/LDAP_CA/index.txt# echo 01 > /etc/pki/LDAP_CA/serial
Generate CA key
# cd /etc/pki/LDAP_CA/private# openssl genrsa -out ca_server.key 4096Generating RSA private key, 4096 bit long modulus (2 primes).......................................++++.............................................................................................++++e is 65537 (0x010001)
Generate CA certificate
# cd /etc/pki/LDAP_CA# openssl req -new -x509 -days 365 -key private/ca_server.key -out ca_server.pemYou are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:GBState or Province Name (full name) [Some-State]:EnglandLocality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Intellitect WaterOrganizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:ubuntu2004.localdomainEmail Address []:jpmigue@gmail.com
Create certificate extensions configuration file
# cat /root/server_cert_ext.cnf[v3_ca]basicConstraints = CA:FALSEnsCertType = servernsComment = "OpenSSL Generated Server Certificate"subjectKeyIdentifier = hashauthorityKeyIdentifier = keyid,issuer:alwayskeyUsage = critical, digitalSignature, keyEnciphermentextendedKeyUsage = serverAuth
Modify openssl configuration file
dir = ./LDAP_CA # Where everything is kept
Generate private key for server certificate
# cd /etc/pki/LDAP_CA/private# openssl genrsa -out ldap_server.key 4096Generating RSA private key, 4096 bit long modulus (2 primes)...................++++.............++++e is 65537 (0x010001)
Generate server certificate CSR
# cd /etc/pki/LDAP_CA/# openssl req -new -key private/ldap_server.key -out ldap_server.csrYou are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:GBState or Province Name (full name) [Some-State]:EnglandLocality Name (eg, city) []:Organization Name (eg, company) [Internet Widgits Pty Ltd]:Intellitect WaterOrganizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:ubuntu2004.localdomainEmail Address []:jpmigue@gmail.com
Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:
Generate server certificate
# cd /etc/pki# openssl ca -keyfile LDAP_CA/private/ca_server.key -cert LDAP_CA/ca_server.pem -in LDAP_CA/ldap_server.csr -out LDAP_CA/ldap_server.pem -extensions v3_ca -extfile /root/server_cert_ext.cnfUsing configuration from /usr/lib/ssl/openssl.cnfCheck that the request matches the signatureSignature okCertificate Details: Serial Number: 1 (0x1) Validity Not Before: May 31 22:47:44 2022 GMT Not After : May 31 22:47:44 2023 GMT Subject: countryName = GB stateOrProvinceName = England organizationName = Intellitect Water commonName = ubuntu2004.localdomain emailAddress = jpmigue@gmail.com X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Cert Type: SSL Server Netscape Comment: OpenSSL Generated Server Certificate X509v3 Subject Key Identifier: E5:43:BD:82:36:92:3D:2A:E3:7B:6B:EA:EC:DA:E3:32:4B:59:7C:E9 X509v3 Authority Key Identifier: keyid:ED:1A:20:A8:EC:FB:9E:CB:C8:E0:95:72:4B:0F:3D:61:78:F0:65:F5 DirName:/C=GB/ST=England/O=Intellitect Water/CN=ubuntu2004.localdomain/emailAddress=jpmigue@gmail.com serial:27:03:2E:03:21:F3:7C:BD:1B:FC:B3:3A:AD:F6:A2:CA:2D:79:C4:49
X509v3 Key Usage: critical Digital Signature, Key Encipherment X509v3 Extended Key Usage: TLS Web Server AuthenticationCertificate is to be certified until May 31 22:47:44 2023 GMT (365 days)Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]yWrite out database with 1 new entriesData Base Updated