X509TrustManager Override without allowing ALL certs?

前端 未结 2 2057
旧巷少年郎
旧巷少年郎 2020-12-09 13:15

I am currently overriding X509TrustManager to allow all certs as a temporarily \'solution\' (an unsafe one at that). I am trying to figure out how I would go about adding in

相关标签:
2条回答
  • 2020-12-09 13:53

    All you need to do is return the certificate from getAcceptedIssuers. See this

     InputStream inStream = new FileInputStream("fileName-of-cert");
     CertificateFactory cf = CertificateFactory.getInstance("X.509");
     X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream);
     inStream.close();
    

    and then return that in an array within the method

    0 讨论(0)
  • 2020-12-09 14:08

    One possibility would be to temporarily add the problematic certificate to your JVM's key store as a trusted certificate.

    0 讨论(0)
提交回复
热议问题