Как правильно генерировать ключи, сертификаты...?JAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как правильно генерировать ключи, сертификаты...?

Сообщение Anonymous »

Я использую Spring 3.4.1, Java/JDK 23, Windows 10 x64 pro, OpenSSL 3.2.3 от 3 сентября 2024 г. Я прочитал на https://techdocs.broadcom.com/us/en/vmware-tanzu/ весна/tanzu-spring/commercial/spring-tanzu/service-registry-enable-mtls.html
Мой application.yml

Код: Выделить всё

server:
port: 8000
ssl:
bundle: server
client-auth: NEED
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/xx000?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
username: xxx
password: xxx
ssl:
bundle:
pem:
server:
keystore:
certificate: server_tls.crt
private-key: server_tls.key
private-key-password: changeit

truststore:
certificate: ca_tls.crt
private-key-password: changeit

Мои команды

Код: Выделить всё

# Generate the private key for the server.
openssl genpkey -algorithm RSA -out server_tls.key -aes256

Код: Выделить всё

# Generate the certificate signing request (CSR) for the server.
openssl req -new -key server_tls.key -out server_tls.csr -subj "/CN=localhost.com"

Код: Выделить всё

# Self-sign the server certificate (for testing purposes, you could also have it signed by a CA).
openssl x509 -req -in server_tls.csr -signkey server_tls.key -out server_tls.crt -days 365
# Optionally, you could also create a more robust certificate using a certificate authority (CA) if you have one.

Код: Выделить всё

# Generate the private key for the CA.
openssl genpkey -algorithm RSA -out ca_tls.key -aes256

Код: Выделить всё

# Generate the self-signed certificate for the CA.
openssl req -x509 -key ca_tls.key -out ca_tls.crt -days 3650 -subj "/CN=My Custom CA"

Код: Выделить всё

# Convert the server certificate and key to a Java Keystore format.
openssl pkcs12 -export -in server_tls.crt -inkey server_tls.key -out server.p12 -name tomcat

Код: Выделить всё

# Convert the PKCS12 keystore into a Java Keystore (JKS).
keytool -importkeystore -destkeystore server.jks -srckeystore server.p12 -srcstoretype PKCS12
Команда в операционной системе Windows:

Код: Выделить всё

curl --cacert ca_tls.crt --cert server_tls.crt --key server_tls.key https://localhost:8000/actuator/health
Когда запрашивается пароль, я ввел команду «changeit» во всех случаях.
Я уловил это

Код: Выделить всё

curl: (58) schannel: Failed to import cert file server_tls.crt, last error is 0x80092002
В чем я ошибаюсь? (в команде создания ключа, сертификата, завитка или чего-то еще?)

Подробнее здесь: https://stackoverflow.com/questions/793 ... keys-certs
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»