java 如何在 Spring 上配置 SSL/HTTPS?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30377812/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 17:01:15  来源:igfitidea点击:

How to configure SSL / HTTPS on Spring?

javaspringsslhttps

提问by David Castillo

I'm working on a Spring Java app that requires HTTPS, and I followed Spring's guide to configure SSL.

我正在开发一个需要 HTTPS 的 Spring Java 应用程序,我按照Spring 的指南来配置 SSL

My application.properties file contains the following:

我的 application.properties 文件包含以下内容:

server.port = 8443
server.ssl.key-store = classpath:keystore.p12
server.ssl.key-store-password = password
server.ssl.key-password = password
server.ssl.keyStoreType = JCEKS
server.ssl.keyAlias = alias

When the app is run, the console outputs Tomcat started on port(s): 8443 (https), but any request to the server results in a 0 NO RESPONSEstatus.

当应用程序运行时,控制台输出Tomcat started on port(s): 8443 (https),但对服务器的任何请求都会导致0 NO RESPONSE状态。

What am I missing?

我错过了什么?

采纳答案by David Castillo

Problem seems to be the specified encryption algorithm. I was generating the key using keytool, with -keyalg AES. Changed it to use RSA with -keyalg RSAand it works now.

问题似乎是指定的加密算法。我正在使用keytool,生成密钥-keyalg AES。将其更改为与 RSA 一起使用,-keyalg RSA现在可以使用了。