0

I'm running some automation tests, using azure SDK. It works fine at first, after a couple of tries to authenticate(each test performs new authentication), getting the below error. What could be the reason?

enter image description here

08:39:45 [jsystem] [pool-54-thread-1] INFO com.microsoft.aad.adal4j.AuthenticationAuthority - [Correlation ID: 5ceb4f83-441b-4263-8134-b91a69101b2d] Instance discovery was successful 
08:39:46 [jsystem] [pool-54-thread-1] ERROR com.microsoft.aad.adal4j.AuthenticationContext - [Correlation ID: 5ceb4f83-441b-4263-8134-b91a69101b2d] Execution of class com.microsoft.aad.adal4j.AcquireTokenCallable failed. 
08:39:46 [jsystem] javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate ECDH keypair 
08:39:46 [jsystem] at sun.security.ssl.Alert.createSSLException(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.TransportContext.fatal(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.TransportContext.fatal(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.TransportContext.fatal(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLSocketImpl.handleException(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source) 
08:39:46 [jsystem] at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source) 
08:39:46 [jsystem] at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) 
08:39:46 [jsystem] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source) 
08:39:46 [jsystem] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source) 
08:39:46 [jsystem] at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AdalOAuthRequest.configureHeaderAndExecuteOAuthCall(AdalOAuthRequest.java:145) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AdalOAuthRequest.send(AdalOAuthRequest.java:83) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AdalTokenRequest.executeOAuthRequestAndProcessResponse(AdalTokenRequest.java:87) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AuthenticationContext.acquireTokenCommon(AuthenticationContext.java:930) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:70) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AcquireTokenCallable.execute(AcquireTokenCallable.java:38) 
08:39:46 [jsystem] at com.microsoft.aad.adal4j.AdalCallable.call(AdalCallable.java:47) 
08:39:46 [jsystem] at java.util.concurrent.FutureTask.run(Unknown Source) 
08:39:46 [jsystem] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
08:39:46 [jsystem] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
08:39:46 [jsystem] at java.lang.Thread.run(Unknown Source) 
08:39:46 [jsystem] Caused by: java.lang.RuntimeException: Could not generate ECDH keypair 
08:39:46 [jsystem] at sun.security.ssl.ECDHKeyExchange$ECDHEPossession.(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.ECDHClientKeyExchange$ECDHEClientKeyExchangeProducer.produce(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.ClientKeyExchange$ClientKeyExchangeProducer.produce(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLHandshake.produce(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.ServerHelloDone$ServerHelloDoneConsumer.consume(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLHandshake.consume(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.HandshakeContext.dispatch(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.HandshakeContext.dispatch(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.TransportContext.dispatch(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLTransport.decode(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLSocketImpl.decode(Unknown Source) 
08:39:46 [jsystem] at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(Unknown Source)

1 Answer 1

0

Test with your code like this, and it works well. Please try to check the parameters in the code, and test them in Postman.

import com.microsoft.azure.credentials.ApplicationTokenCredentials;
import com.microsoft.azure.AzureEnvironment;
import com.microsoft.azure.management.Azure;    
import com.microsoft.rest.LogLevel;

......

String CLIENT_ID = "application-id";
String CLIENT_SECRET = "client-secret";
String TENANT = "tenant-id";
String Subscription_id = "subscription-id";

ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(CLIENT_ID, TENANT, CLIENT_SECRET,
        AzureEnvironment.AZURE);
        
try {   
    Azure azure = Azure.configure().withLogLevel(LogLevel.NONE).authenticate(credentials).withSubscription(Subscription_id);
    System.out.println(azure.tenantId());    
} catch (Exception e) {
    e.printStackTrace();
}

Dependencies:

    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-client-runtime</artifactId>
        <version>1.7.12</version>
    </dependency>

    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-client-authentication</artifactId>
        <version>1.7.12</version>
    </dependency>

    <dependency>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure</artifactId>
        <version>1.39.1</version>
    </dependency>

enter image description here

Another method to authenticate and get access token.


There is an error "java.lang.RuntimeException: Could not generate ECDH keypair" in your issue. Please refer to here.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the answer, changed the description of my problem so it will be more understandable
Could you share when you got the error? What's the difference with others?
Got the error while trying to authenticate, there is no difference with other tests, running the same azure authentication each time. maybe there is some limitation?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.