OpenSSL: Criando uma Autoridade Certificadora (CA)
Vou mostrar como criar uma Autoridade Certificadora (CA).
Esse CA vai ser utilizado nos meus exemplos de configuração IBM Sterling.
Procedimento
Instalando
1) Instalando os Pacotes
yum install -y openssl
Criando uma Autoridade Certificadora
Criando a CA
Execute o comando
openssl req -new -x509 -key ca-key.pem -out ca-cert.pem -days 3650 \ -subj "/C=BR/ST=DF/L=/O=Test Net Ltd/CN=Autoridade Certificadora da Test Net Ltd/emailAddress=[email protected]"
Com exceção do Common Name, aceite os valores default, pois já alteramos o openssl.cnf anteriormente.
Informe
CA certificate filename (or enter to create)<ENTER> Making CA certificate ... Generating a 2048 bit RSA private key .........+++ ...........................+++ writing new private key to '/etc/pki/CA/private/./cakey.pem' Enter PEM pass phrase:<INFORME UMA SENHA E ENTER> Verifying - Enter PEM pass phrase:<INFORME UMA SENHA E ENTER> ----- 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 '.', the field will be left blank. ----- Country Name (2 letter code) [BR]:<ENTER> State or Province Name (full name) [DF]:<ENTER> Locality Name (eg, city) [Brasilia]:<ENTER> Organization Name (eg, company) [Test Net Ltd]:<ENTER> Organizational Unit Name (eg, section) [Ditec]:<ENTER> Common Name (eg, your name or your server's hostname) [Autoridade Certificadora da Test Net Ltd]:<ENTER> Email Address [[email protected]]:<ENTER> Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []:<ENTER> An optional company name []:<ENTER> Using configuration from /etc/pki/tls/openssl.cnf Enter pass phrase for /etc/pki/CA/private/./cakey.pem:<INFORME A SENHA ANTERIOR E ENTER> Check that the request matches the signature Signature ok Certificate Details: Serial Number: 84:8f:08:9b:5d:d6:df:8f Validity Not Before: Nov 4 00:28:50 2020 GMT Not After : Oct 11 00:28:50 2120 GMT Subject: countryName = BR stateOrProvinceName = DF organizationName = Test Net Ltd organizationalUnitName = Ditec commonName = Autoridade Certificadora da Test Net Ltd emailAddress = [email protected] X509v3 extensions: X509v3 Subject Key Identifier: 9B:96:1D:50:C6:E3:69:6B:07:99:17:17:50:91:80:6F:D8:14:4A:C5 X509v3 Authority Key Identifier: keyid:9B:96:1D:50:C6:E3:69:6B:07:99:17:17:50:91:80:6F:D8:14:4A:C5 X509v3 Basic Constraints: CA:TRUE Certificate is to be certified until Oct 11 00:28:50 2120 GMT (36500 days) Write out database with 1 new entries Data Base Updated
Disponibilizando a CA
Agora que criamos a CA, vamos disponibilizar ele para importar no Navegador, ou para ser importado na Trust Store.
O certificado raiz é o arquivo
- Linux: /etc/pki/CA/cacert.pem
- Windows: C:\Program Files\OpenSSL-Win64\bin\demoCA\cacert.pem
Renomeie-o para ca-company.crt e coloque em um site interno para download ou distribua via Police no MS Windows (GPO).
Criando um par de Chaves
Execute o comando no Windows
perl CA.pl -newreq
ou no Linux
./CA -newreq
Informe
Country Name (2 letter code) [BR]: <ENTER> State or Province Name (full name) [DF]:<ENTER> Locality Name (eg, city) [Brasilia]:<ENTER> Organization Name (eg, company) [Test Net Ltd]: <ENTER> Organizational Unit Name (eg, section) [Ditec]:<ENTER> Common Name (eg, YOUR name) []:www.test.net Email Address [[email protected]]:<ENTER>
Será criado 2 arquivos:
- newreq.pem: Arquivo de requisição (CSR)
- newkey.pem: Chave privada assinada
Assine a chave criada OpenSSL: Assinando um CSR com a nossa CA
Ver também