Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

java.security.ProviderException: Could not derive key

59038a00-7691-4322-8907-009e5c336c4dApr 3 2018 — edited Apr 3 2018

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

Comments

mNem
Answer

did you try right-click on the project name from Projects panel and Copy ... option?

Marked as Answer by OTG-467455 · Sep 27 2020
mNem

If I were you, for "exploring different scenarios", I would just stick with creating a new class (copy the existing one if you like) and make modifications all in the same project (instead of cloning the entire project).

HTH.

OTG-467455

Hi mNem,  Both of your suggestions are good.  I just wanted to create a replica, mess around and then drop it.  So the clone works just right for me.  Thanks for your quick thinking.

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 1 2018
Added on Apr 3 2018
0 comments
4,158 views