CERTIFICADO SSL SPRINGBOOT

De Tek-System Wiki
Ir para navegação Ir para pesquisar

Configuração certificado SSL

OBS: SERVIDOR TOMCAT!!!!


Solucao encontrada ate o momento:

PARA GERAR CSR

  • 1 - keytool -genkey -keyalg RSA -alias certificadossl -keystore certificadossl.keystore -keysize 2048
  • 2 - keytool -certreq -keyalg RSA -alias certificadossl -file certificadossl.csr -keystore certificadossl.keystore


PARA OBTER CERTIFICADO A PARTIR DO DOCUMENTO RECEBIDO DA SERTIGO(COMODO)

Na altura dos documentos recebidos, adicione o keystore antigo entre eles (OBS: FAÇA UMA COPIA DO KEYSTORE CASO DE PROBLEMA) O KEYSTORE EH O ARQUIVO GERADO JUNTO AO CSR, ESSE ARQUIVO EH MODIFICADO NOS PASSOS A SEGUIR PARA CONTER O CERTIFICADO.

  • 1 - keytool -import -trustcacerts -alias root -file AddTrustExternalCARoot.crt -keystore certificadossl.keystore
  • 2 - keytool -import -trustcacerts -alias INTER -file USERTrustRSAAddTrustCA.crt -keystore certificadossl.keystore
  • 3 - keytool -import -trustcacerts -alias INTER2 -file SectigoRSADomainValidationSecureServerCA.crt -keystore certificadossl.keystore
  • 4 - keytool -import -alias certificadossl -file ts_teksystem_com_br.crt -keystore certificadossl.keystore

OBS: NAO EH PRECISO ENTRAR NO ARQUIVO BIN DO JAVA


Classe no java para apontar para portas diferentes:


   @Configuration
   @Profile(value="producao")
   public class RedirecionamentoHttpParaHtppsConfig {
    @Value("${http.port}")
     private int httpPort;
     @Bean
     public EmbeddedServletContainerCustomizer customizeTomcatConnector(){
       return container -> {
         if (container instanceof TomcatEmbeddedServletContainerFactory) {
           TomcatEmbeddedServletContainerFactory containerFactory =
                   (TomcatEmbeddedServletContainerFactory) container;
           Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);
           connector.setPort(httpPort);
           containerFactory.addAdditionalTomcatConnectors(connector);
         }
       };   
     }
   }

Properties do spring em PRODUÇÃO!

   http.port=8080
   server.port=8090
   # Tell Spring Security (if used) to require requests over HTTPS
   security.require-ssl=true
   # The format used for the keystore
   server.ssl.key-store-type=JKS
   # The path to the keystore containing the certificate
   server.ssl.key-store=classpath:certificadossl.keystore
   # The password used to generate the certificate
   server.ssl.key-store-password=chavemestra
   # The alias mapped to the certificate
   server.ssl.key-alias=certificadossl
   #Certificado SSL

Sem ser produção NÃO MEXE!


Fonte CSR Java: https://www.sectigo.com.br/suporte/csr-tomcat.php Fonte Apos CSR: https://www.sectigo.com.br/suporte/manual-tomcat.php Fonte Local da geração de certificado: https://www.positivessl.com.br/index.php