Forum Stats

  • 3,840,394 Users
  • 2,262,599 Discussions
  • 7,901,262 Comments

Discussions

java.security.ProviderException: Could not derive key

Hi,

I am calling Soap Based Web Services from an application which is deployed in J Boss server. Part of my code snippet is given below.

Socket socket = new Socket();

SocketAddress sockaddr = new InetSocketAddress("xxxx", 8080);

socket.connect(sockaddr, 10000);

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(socket.getInetAddress(), 8080));

SOAPMessage soapMessage = createSOAPRequest(username, password, soapAction);

ByteArrayOutputStream stream = new ByteArrayOutputStream();

soapMessage.writeTo(stream);

String message = new String(stream.toByteArray(), "UTF-8");

URL url = new URL(soapEndpointUrl);

URLConnection connection = url.openConnection();

HttpURLConnection httpConn = (HttpURLConnection)connection;

ByteArrayOutputStream bout = new ByteArrayOutputStream();

byte[] buffer = new byte[message.length()];

buffer = message.getBytes();

bout.write(buffer);

byte[] b = bout.toByteArray();

httpConn.setRequestProperty("Content-Length", String.valueOf(b.length));

httpConn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");

httpConn.setRequestProperty("SOAPAction", soapAction);

httpConn.setRequestMethod("GET");

httpConn.setDoOutput(true);

httpConn.setDoInput(true);

OutputStream outputStream = httpConn.getOutputStream();

outputStream.write(b);

outputStream.close();

If I run this code as a standalone Java Program out of J Boss, it's working fine. But the same code is integrated in the main application and deployed in J Boss server is throwing with the below Exception. I am using jdk 1.8 and imported the respective certificate in jre/lib/security.

Caused by: javax.net.ssl.SSLException: java.security.ProviderException: Could not derive key

Caused by: java.security.ProviderException: Could not derive key

at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:133)

at sun.security.ec.ECDHKeyAgreement.engineGenerateSecret(ECDHKeyAgreement.java:163)

at javax.crypto.KeyAgreement.generateSecret(KeyAgreement.java:648)

at sun.security.ssl.ECDHCrypt.getAgreedSecret(ECDHCrypt.java:102)

at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1061)

at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)

at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)

at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)

at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)

at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)

at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)

... 85 common frames omitted

Caused by: java.security.InvalidAlgorithmParameterException: null

Please help me in find out the root cause and solution.

Thanks,

Srinivas

This discussion has been closed.