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 Answers1

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.

unknown
  • 6,778
  • 1
  • 5
  • 14