Spring Boot - enable and configure SSL certificate

后端 未结 4 509
Happy的楠姐
Happy的楠姐 2021-01-11 15:25

I have this certificates / files in order to enable SSL for my application:

I found out that this properties are needed for Spring Boot to enable HTTPS:

相关标签:
4条回答
  • 2021-01-11 15:46
    server.port=8089
    server.ssl.enabled=true
    server.ssl.key-store=src/main/resources/keystore.p12
    server.ssl.key-store-password=****
    server.ssl.keyStoreType=PKCS12
    server.ssl.keyAlias=tomcat << This should be the alias of yourfile.12 if you have forgotten just create a new one and replace it>>
    

    And dnt forget to add

    security.require-ssl=true <<Tell Spring Security (if used) to require requests over HTTPS>>
    
    0 讨论(0)
  • 2021-01-11 15:57

    To enable SSL, you must provide a private key, and not a trusted certificate.

    In your keystore, 'tomcat' should be listed as an alias for a privatekeyentry and not a trustedcertentry.

    0 讨论(0)
  • 2021-01-11 15:57

    You have to pack your private keys to PFX file or P12 with specifiyng aliases. So, it will be picked up accordingly from the keyStore after loading materials.

    Use this tool to figure out what alias are:

    keytool -list -storetype pkcs12 -keystore my_debug_keystore.p12 -storepass debug
    
    0 讨论(0)
  • 2021-01-11 16:08

    I'd suggest you create your KeyStore in JKS format:

     keytool -genkey -keyalg RSA -alias my_alias -keystore keystore.jks -storepass password -validity 360 -keysize 2048
    

    then add the configuration:

    server.port=8089
    server.ssl.enabled=true
    server.ssl.key-store=src/main/resources/keystore.jks
    server.ssl.key-store-password=****
    server.ssl.keyStoreType=JKS
    server.ssl.keyAlias=my_alias
    
    0 讨论(0)
提交回复
热议问题