我正在尝试在我的应用程序中启用HTTP和HTTPS。我关注了文档-https://www.baeldung.com/spring-boot-https-self-signed-certificate 并使用以下命令生成:
keytool -genkeypair -alias baeldung -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore baeldung.p12 -validity 3650
Copied baeldung.p12 to src/main/resources/keystroke folder.
Configured below properties in application.properties
server.ssl.key-store-type=PKCS12
server.ssl.key-store=classpath:keystore/baeldung.p12
server.ssl.key-store-password=password
server.ssl.key-alias=baeldung
server.port=8080
http.port=8081
Updated POM:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/keystore/*.p12</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/keystore/*.p12</include>
</includes>
</resource>
</resources>
我已经添加了Jetty的配置文件。
Updated
\jre\lib\security\java.security with
keystore.type=pkcs12
All the above are done, but getting an error
Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=111, too big.
at sun.security.util.DerInputStream.getLength(Unknown Source)
at sun.security.util.DerValue.init(Unknown Source)
at sun.security.util.DerValue.<init>(Unknown Source)
at sun.security.util.DerValue.<init>(Unknown Source)
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)
I tried to configure above all, but application fails by not identifying the keystore, could not figure out if any more configuration is missing for this. Please let me know if there is any possibility of corruption of the file generated in keystore.
Please help.
Thanks.