certificados_digitais:config_apache

Essa é uma revisão anterior do documento!


Geração e configuração dos certificados no Apache

Em primeiro lugar, o módulo ssl do Apache deve estar ativo. O comando para ativá-lo é:

a2enmod ssl

Once Apache is running with mod_ssl you'll have to register the domain component of your webserver (that is “example.org” for the server “www.example.org”) with your CAcert account. To do this go to CAcert homepage, log in, click “Domains → Add” and follow the instructions there. If your Domain is shown as “verified” on “Domains → Show” you can continue and generate a certificate for your server.

Get openssl if it is not already installed on your system. If you can't find it somewhere else you can try the openssl website for a binary version for Windows. Generate a certificate signing request (CSR) using the command:

Crie os dois arquivos necessários para a geração e o uso do certificado no Apache com o seguinte comando:

openssl req -newkey rsa:2048 -subj /CN=<domínio> -nodes -keyout <nome do arquivo da chave privada>.pem -out <nome do arquivo da CSR>.pem

E crie um arquivo texto em branco para armazenar o conteúdo do certificado que será gerado:

touch <nome do arquivo do certificado>

O padrão de nomes utilizados em nosso VPS é:

  • Arquivo da chave privada: domínio_subdomínio-key.pem (ex. vilarejo_red-key.pem)
  • Arquivo da CSR: domínio_subdomínio-csr.pem (ex. vilarejo_red-csr.pem)
  • Arquivo do certificado: domínio_subdomínio-cert.pem (ex. vilarejo_red-cert.pem)

Após isso, entre no sítio do CACert e lá selecione a opção Certificado de Servidor e Novo. Será aberta uma página com os termos de uso e dois campos: um para comentários (é um campo livre somente para o seu controle e não interfere na geração do certificado) e outro para colar o conteúdo do arquivo de CSR gerado anteriormente. Agora, abra o arquivo de CSR gerado em um editor de textos, copie todo o seu conteúdo (inclusive as linhas —–BEGIN CERTIFICATE REQUEST—– e —–END CERTIFICATE REQUEST—–) e cole na caixa de texto correspondente. Ao final, clique no botão Enviar. Em seguida verifique se o nome que aparece corresponde ao domínio para o qual será gerado o certificado e clique novamente em Enviar. Com isso o certificado será gerado.

Novamente, copie todo o conteúdo gerado (inclusive as linhas —–BEGIN CERTIFICATE—– e —–END CERTIFICATE—–), e cole o conteúdo no arquivo de certificado, que foi criado anteriormente e está em branco.

Go to CACert, log in, and select “Server certificates → New”. If a Class 3 certificate is available for you I'd advise you to select a Class 3 certificate.

Use Copy/Paste to input your CSR (the content of example_csr.pem in the above example) into the big editor box. Be sure to include the header and footer lines ( —–BEGIN CERTIFICATE REQUEST—– and —–END CERTIFICATE REQUEST—– ) and check that after the paste operation the request has not been truncated.

Click on “Send” and your certificate will be generated. That is, if you did not make a mistake. If you made one, read the error message, try to understand what it wants to say to you and try again while skipping the mistake. ;) Use Copy/Paste with your favourite editor to save the certificate to a file (let's call the file example_cert.pem). Move the private key and the certificate to a convenient location. Standard Apache installations provide the directories ssl.key for the private key and ssl.crt for the certificate in the configuration directory. If you want to keep the CSR for later reference (though you probably won't need it anymore) there also is a directory named ssl.csr.

If using a Class 3 certificate as proposed you'll need the certificate chain file. This is just the Class 3 root certificate and the Class 1 root certificate in PEM format concatenated. Do it yourself or download it from the attachments. Store the certificate chain file in the ssl.crt directory and let's call it CAcert_chain.pem for future reference. Now all that remains to be done is to correctly configure Apache's mod_ssl. To use the certificate set the following directives in your SSL-configuration:

SSLCertificateFile <Path to your certificate file>/example_cert.pem SSLCertificateKeyFile <Path to your key file>/example_key.pem SSLCertificateChainFile <Path to your chain file>/CAcert_chain.pem .

This is it. Restart your Apache and see if it works!

http://wiki.cacert.org/SimpleApacheCert

  • certificados_digitais/config_apache.1405166327.txt.gz
  • Última modificação: 2014/07/12 11:58
  • por aracnus