Hostname in certificate didn't match?

前端 未结 5 1111
挽巷
挽巷 2020-12-13 11:37

I try to connect to a server with a self-signed certificate. I use this code to accept all certificates.

public class CertificateAcceptor {

    public void          


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 12:17

    ALLOW_ALL is not the correct answer. You should set up your certificate with the correct name by using keytool with the ext extension:

    keytool -genkeypair \
       -keystore keystore.jks \
      -dname "CN=OLEKSIYS-W3T, OU=Sun Java System Application Server, O=Sun Microsystems, L=Santa Clara, ST=California, C=US" \
      -keypass changeit \
      -storepass changeit \
      -keyalg RSA \
      -keysize 2048 \
      -alias default \
      -ext SAN=DNS:localhost,IP:127.0.0.1 \
      -validity 9999
    

    See http://tersesystems.com/2014/03/23/fixing-hostname-verification/ for more details.

提交回复
热议问题