I am trying to assume an aws role to connect to different service. I have following implementation which is not working fine. It is giving me error
javax.net.ssl.SSLException: Connection reset
Any thoughts on how to fix this?
public static Credentials assumeRole() {
String targetRoleArn = "xxx";
String assumedRoleName = "xxx";
String accessKey = "xxx";
String secretKey = "xxx";
Credentials assumedCredentials = null;
AwsBasicCredentials credentials = AwsBasicCredentials.create(accessKey, secretKey);
StsClient stsClient = StsClient.builder()
.region(Region.US_EAST_1)
.credentialsProvider(StaticCredentialsProvider.create(credentials))
.build();
try {
AssumeRoleRequest roleRequest = AssumeRoleRequest.builder()
.roleArn(targetRoleArn)
.roleSessionName(assumedRoleName)
.build();
AssumeRoleResponse roleResponse = stsClient.assumeRole(roleRequest);
assumedCredentials = roleResponse.credentials();
} catch (StsException e) {
System.err.println(e.getMessage());
System.exit(1);
}
return assumedCredentials;
}