title: Trying to connect to EJBCA Web Service and getting bad_certificate at ServerHelloDone
body: <p>I apologize for the really newbie quality of this question.</p>
  
  <p>I have a EJBCA server set up and two CA's on it.  One is the default one I created the server instance with.</p>
  
  <p>I took the wsdl from EJBCA and generated Java code with it.</p>
  
  <p>Using the generated java client code, I'm trying to open a connection to the EJBCA server.<br>
  According to EJBCA here: <a href="http://ejbca.sourceforge.net/ws/org/ejbca/core/protocol/ws/client/gen/package-summary.html" rel="nofollow">http://ejbca.sourceforge.net/ws/org/ejbca/core/protocol/ws/client/gen/package-summary.html</a></p>
  
  <p>This the way to initialize a connection to the server.  </p>
  
  <p>I took the truststore.jks file from the EJBCA server as well as the superadmin.jks file from the server and put it on my local machine and made it available for my app as a resource.</p>
  
  <pre><code>val truststore = this.getClass.getClassLoader.getResource("pathto/wsTrustStore")
      System.setProperty("javax.net.ssl.trustStore", truststore.getFile)
      System.setProperty("javax.net.ssl.trustStorePassword","wsTrustStorePassword")
  
      val keystore = this.getClass.getClassLoader.getResource("pathto/superadminKeyStore")
      System.setProperty("javax.net.ssl.keyStore", keystore.getFile)
      System.setProperty("javax.net.ssl.keyStorePassword", "superadminKeyStorePassword")
  
      val qname = new QName(componentConfig.getString("http://ws.protocol.components.ejbca.org/"), "EjbcaWSService")
      val service = new EjbcaWSService(new URL("https://myejbcaserver.com:8443/ejbca/ejbcaws/ejbcaws?wsdl"), qname)
  
      service.getEjbcaWSPort
  </code></pre>
  
  <p>this is the java ssl debug logs</p>
  
  <p><strong>* CertificateRequest
  Cert Types: RSA, DSS, ECDSA
  Cert Authorities:
  
  <em></strong> ServerHelloDone
  *</em>* Certificate chain</p>
  
  <hr>
  
  <p><em>*</em> ClientKeyExchange, RSA PreMasterSecret, TLSv1
  New I/O  worker #2, WRITE: TLSv1 Handshake, length = 141</p>
  
  <p>...</p>
  
  <p>New I/O  worker #2, WRITE: TLSv1 Change Cipher Spec, length = 1
  <em>*</em> Finished
  verify_data:  { 95, 232, 182, 57, 141, 10, 130, 36, 152, 210, 86, 173 }</p>
  
  <hr>
  
  <p>New I/O  worker #2, WRITE: TLSv1 Handshake, length = 48
  New I/O  worker #2, waiting for close_notify or alert: state 1
  New I/O  worker #2, READ: TLSv1 Alert, length = 2
  New I/O  worker #2, RECV TLSv1 ALERT:  fatal, bad_certificate
  %% Invalidated:  [Session-1, TLS_RSA_WITH_AES_128_CBC_SHA]
  New I/O  worker #2, called closeSocket()
  New I/O  worker #2, Exception while waiting for close javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
  New I/O  worker #2, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate</p>
  
  <p>Is there anyone who has experience with this that can help me out?</p>