Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

WebService interfaces in Java access EJBCA at this stage

liwf
2014-05-21
2014-05-24
  • liwf
    liwf
    2014-05-21

    I have create client keyStore and certificate in my EJBCA publick Web,and in my java code I use it like this:
    Provider tlsProvider = new TLSProvider();
    Security.addProvider(tlsProvider);
    Security.setProperty("ssl.TrustManagerFactory.algorithm", "AcceptAll");
    Security.setProperty("ssl.KeyManagerFactory.algorithm", "NewSunX509");

        CertTools.installBCProvider();
        String urlstr = "https://222.161.197.250:8443/ejbca/ejbcaws/ejbcaws?wsdl";
        System.setProperty("javax.net.ssl.trustStore","C:\\Users\\Administrator\\truststore.jks");
        System.setProperty("javax.net.ssl.trustStorePassword","111111");
        //System.setProperty("javax.net.ssl.keyStoreType", "jks");
        System.setProperty("javax.net.ssl.keyStore","D:\\Documents\\Downloads\\tomcat.jks");
        System.setProperty("javax.net.ssl.keyStorePassword", "111111");
    
        QName qname = new QName("http://ws.protocol.core.ejbca.org/","EjbcaWSService");
        EjbcaWSService service = null;
        try {
            service = new EjbcaWSService(new URL(urlstr), qname);
        } catch (MalformedURLException e1) {
            e1.printStackTrace();
        }
        EjbcaWS ws = service.getEjbcaWSPort();
    

    but it always has Caused by: java.io.IOException: HTTPS hostname wrong: should be <222.161.197.250>
    or Caused by: java.security.cert.CertificateException: No subject alternative names present
    can someBody tell me why,I didn't get rid of for a few days, is to add the client's certificate to the server trustStore?

     
  • The TLS server certificate is invalid. A better solution is creating a real TLS certificate than trying to get around the problem.

    give the host a proper name and put the IP in "hosts" file to begin with.

    Cheers
    Anders

     
    • liwf
      liwf
      2014-05-24

      Now, I want to use EJBCA WebService interface in java code, but after I installed ejbca at this stage,I don't know what to do? Should i use the WEB GUI to create a CA certificate 、keyStore and trustStore then set them in my java code? Can you tell me what should i do?