current position:Home>HTTP becomes HTTPS, self-made certificate

HTTP becomes HTTPS, self-made certificate

2022-04-29 15:17:14WuWuII

winodw In the environment cmd Generate

Generate p12

grammar

keytool -genkey -alias Alias -storetype Keystore type -keyalg Algorithm -keysize How many -keystore certificate -validity Effective time

example

D:\>keytool -genkey -alias wzw -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore wzw.p12 -validity 3650

After execution, you will be asked to fill in some information , region 、 Name or something , Can not fill
Generated in the current directory , Here it is D Disk execution , So in D disc
 Insert picture description here
Check it out. , Display the contents of the certificate
 Insert picture description here

springboot Use in

Copy p12 To project , I put it in resources Next , Modify the configuration file
application.properties

# The name of the certificate you generated 
server.ssl.key-store=classpath:wzw.p12
# Keystore password 
server.ssl.key-store-password=123456
# Key type 
server.ssl.key-store-type:PKCS12
# Alias 
server.ssl.key-alias=wzw

Because it's a self-made Certificate , So show insecure connections , Just click to continue the visit
 Insert picture description here

JKS certificate

keytool -genkey -alias wzw -keypass 123456 -keyalg RSA -keysize 1024 -validity 3650 -keystore wzw.keystore -storepass wzw

application.properties

server.ssl.key-store=classpath:wzw.keystore
server.ssl.key-store-password=123456
server.ssl.key-store-type=JKS
server.ssl.keyAlias=wzw

pfx turn jks

keytool -importkeystore -srckeystore wzw.com.pfx -srcstoretype pkcs12 -destkeystore wzw.jks -deststoretype JKS

## See aliases

keytool -list -v -keystore wzw.p12

They are self-made certificates , If you need secure certificate access , You can go to the service provider to buy and download , You can also have a restricted and secure certificate access :https://www.cnblogs.com/lvzhenjiang/p/14198942.html, The second method of connection , You can refer to

copyright notice
author[WuWuII],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291359555918.html

Random recommended