spbgovbr/sei-docker

SSL no sei-docker

abreujean opened this issue · 8 comments

Olá @marlinhares
Como eu posso ativar o ssl no sei-docker usando Let's Encrypt?

Editing...

Olá @abreujean,

Tem várias formas, não é bem o escopo desse projeto, mas vou mostrar algumas ações possíveis:

  1. Use o letsencrypt no seu proxy externo, do proxy externo vc redireciona via proxy-transparente para o seu servidor ou vm interna com o sei-docker rodando (ai no caso o sei-docker pode estar com qualquer cert inclusive o auto-assinado. O usuário vai ver apenas o cert válido letsencrypt)

  2. Use um orquestrador como o kubernetes ou rancher-cattle

  3. Caso queira colocar o sei-docker com um cert letsencrypt tb é possivel, pode seguir assim, por ex:

  • altere a var APP_HOST no envlocal.env para a url do seu cert, ai no meu usei super.dev..., por ex
export APP_HOST=super.dev.processoeletronico.gov.br
  • posicione o seu letsencrypt válido como um unico arquivo pem no seu desktop e com o nome cert0.pem (veja o formato na resposta abaixo)
  • agora vamos criar o volume certs e copiar o seu letsencrypt valido para ficar no balanceador
make clear && make apagar_volumes
make criar_volume_certs
docker run -it --rm -v local-certs-storage:/t -v ~/Desktop/:/acopiar busybox sh -c "cp /acopiar/cert0.pem /t/"
docker run -it --rm -v local-certs-storage:/t busybox cat /t/cert0.pem
  • agora pode subir normalmente, se for o caso altere o seu /etc/hosts para apontar o nome correto para a sua maquina
make setup
make logs
sudo vim /etc/hosts
curl -v https://super.dev.processoeletronico.gov.br/

*   Trying 127.0.0.1:443...
* Connected to super.dev.processoeletronico.gov.br (127.0.0.1) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* [CONN-0-0][CF-SSL] (304) (OUT), TLS handshake, Client hello (1):
* [CONN-0-0][CF-SSL] (304) (IN), TLS handshake, Server hello (2):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Certificate (11):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Server finished (14):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* [CONN-0-0][CF-SSL] TLSv1.2 (OUT), TLS handshake, Finished (20):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* [CONN-0-0][CF-SSL] TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server did not agree on a protocol. Uses default.
* Server certificate:
*  subject: CN=console.dev.processoeletronico.gov.br
*  start date: Mar 30 12:51:03 2023 GMT
*  expire date: Jun 28 12:51:02 2023 GMT
*  subjectAltName: host "super.dev.processoeletronico.gov.br" matched cert's "super.dev.processoeletronico.gov.br"
*  issuer: C=US; O=Let's Encrypt; CN=R3
*  SSL certificate verify ok.
> GET / HTTP/1.1
> Host: super.dev.processoeletronico.gov.br
> User-Agent: curl/7.87.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Content-length: 0
< Location: http://super.dev.processoeletronico.gov.br/sei/
<
* Connection #0 to host super.dev.processoeletronico.gov.br left intact

Aqui na minha vm ficou fino. Cadeado fechado.

image

aqui o meu cert válido cert0.pem. Alterei apenas a chave privada. O seu deve ter o mesmo formato pem.

-----BEGIN CERTIFICATE-----
MIIFxzCCBK+gAwIBAgISA6SdEUcqU8yOLuoURsdhXFCIMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yMzAzMzAxMjUxMDNaFw0yMzA2MjgxMjUxMDJaMDAxLjAsBgNVBAMT
JWNvbnNvbGUuZGV2LnByb2Nlc3NvZWxldHJvbmljby5nb3YuYnIwggEiMA0GCSqG
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCujhQ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7bCkjCWDcRQJMEhg76fsO3txE+FiYruq9RUWhiF1myv4Q6W+CyBFC
Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCujhQwV0/ghdh2
KOEOxZkD0TeWuO2qVcuiR/CWo0tOTyKeSy9bNOdqruo2jY38FxzMW9Cvbsgcp3jJ
1....
....
WWW8WCaWWWoe4GEzDxzVffw=
-----END PRIVATE KEY-----

Na verdade era pra ser bem mais simples, apenas copiar o teu cert valido para o dir default: ~/sei/certs e rodar make setup
Mas há um bug entao tem q seguir os passos acima. Vou criar uma issue para ajeitar o bug em momento oportuno.

Duvidas avisar

Na minha situação o projeto já está rodando
eu preciso apagar todos os volumes ou eu posso apagar somente os containers o volume local-certs-storage, criando depois e novo e subindo a aplicação?

outra duvida

esse arquivo você gerou juntando os arquivos

cert.pem
chain.pem
privkey.pem
fullchain.pem

certo?

bom dia prezado,

não precisa apagar os volumes.
Basta acessar o volume e jogar la o cert0.pem (assumindo q vc esteja usando o haproxy do projeto)

Depois basta restartar o haproxy. Ou make clear e depois make run pra ele subir td de novo usando os volumes antigos.

O arquivo cert0.pem basta juntar o fullchain.pem e privkey.pem do letsencrypt q vai rodar fino.

@marlinhares Consegui resolver seguindo essas orientações
copiei os arquivos cert.pem, chain.pem, privkey.pem e fullchain.pem para um arquivo cert0.pem e sobrescrevi no volumes de certificados o mesmo, depois de subir novamente os containers funcionou.