OpenSSL: Criando uma Autoridade Certificadora (CA): Difference between revisions
Line 92: | Line 92: | ||
Informe | 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 | |||
Country Name (2 letter code) [BR]: '''<ENTER>''' | Country Name (2 letter code) [BR]: '''<ENTER>''' |
Revision as of 00:38, 4 November 2020
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
Definindo os valores default para a CA
Edite o arquivo
- Linux: /etc/pki/tls/openssl.cnf
- Windows: C:\Program Files\Common Files\SSL\openssl.cnf
e altere os dados da CA. Um exemplo de configuração final (apenas o bloco que interessa):
default_md = sha256 ... default_bits = 2048 ... countryName = Country Name (2 letter code) countryName_default = BR ... stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = DF localityName = Locality Name (eg, city) localityName_default = Brasilia # Esta linha, normalmente, não existe e você deverá criá-la. 0.organizationName = Organization Name (eg, company) 0.organizationName_default = Test Net Ltd organizationalUnitName = Organizational Unit Name (eg, section) organizationalUnitName_default = Ditec # Vamos descomentar essa Linha commonName = Common Name (eg, YOUR name) commonName_max = 64 commonName_default = Autoridade Certificadora da Test Net Ltd emailAddress = Email Address emailAddress_max = 64 emailAddress_default = [email protected] # Vamos criar essa Linha
Salve e feche o arquivo
Edite o arquivo
Alterando o valor default do tempo de duração dos certificados
Edite o arquivo
- Linux: /etc/pki/tls/misc/CA
- Windows: C:\Program Files\OpenSSL-Win64\bin\CA.pl
Alterando o tempo de duração do certificado da CA.
Exemplo para 100 anos:
$CADAYS="-days 36500";
O tempo de duração de um certificado comum é de 3 anos. Exemplo para 10 anos:
$DAYS="-days 3650";
Salve e feche o arquivo
Criando a CA
Execute o comando
perl CA.pl -newca
ou
./CA -newca
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
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 Company]: <ENTER> Organizational Unit Name (eg, section) [Ditec]:<ENTER> Common Name (eg, YOUR name) []:Autoridade Certificadora do Test Net Company Email Address [[email protected]]:<ENTER>
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/tls/demoCA/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
perl CA.pl -newreq
ou
./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 Company]: <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