Copy link to clipboard
Copied
Hello,
We are building a Lambda function which will be triggered by s3 event when a file is uploaded to a folder. Looks like PDF conversion is breaking because of the Credentials. Basically its erroring out while trying parse the private.key.
The same code is working fine in the ECS service, no issues with the Credentials though.
Error:
12:21:48.331 [main] ERROR com.adobe.platform.operation.internal.util.PrivateKeyParser - Unable to parse provided private key: {}
org.bouncycastle.openssl.PEMException: unable to convert key pair: null
This is how I am build the credentials.
Credentials adobeClientCredentials =
Credentials.serviceAccountCredentialsBuilder()
.withClientId("615bebc4cdb94ce38e929222f2690242")
.withClientSecret("ec923417-ceff-4480-bb53-9387910f4274")
.withPrivateKey("private.key")
.withOrganizationId("D5086F726050E0510A495E8E@AdobeOrg")
.withAccountId("E14570F26050F5520A495FF1@techacct.adobe.com")
.build();
But we dont have a private.key , we are just specifying the name.
Need help to understand the issue.
Thanks,
Deba
Copy link to clipboard
Copied
I have also tried adding a private.key in my `resources` folder which worked fine when I tested in local but when lambda function is deployed, its brekaing with the follwing error.
c.a.p.o.internal.util.PrivateKeyParser : Unable to parse provided private key: {}
org.bouncycastle.openssl.PEMException: unable to convert key pair: null
Also I have tried reading the file from a json file, still getting the error.
ClassLoader classLoader = this.getClass().getClassLoader();
String file = classLoader.getResource("credentials.json").getFile();
Credentials adobeClientCredentials = Credentials.serviceAccountCredentialsBuilder()
.fromFile(file)
.build();
{
"client_credentials": {
"client_id": "615bebc4cdb94ce38e929222f2690242",
"client_secret": "ec923417-ceff-4480-bb53-9387910f4274"
},
"service_account_credentials": {
"organization_id": "D5086F726050E0510A495E8E@AdobeOrg",
"account_id": "E14570F26050F5520A495FF1@techacct.adobe.com",
"private_key_file": "private.key"
}
}
Copy link to clipboard
Copied
You should be able to just build the credentials from the JSON file that you got when registering for the credentials.
Credentials credentials = Credentials.serviceAccountCredentialsBuilder()
.fromFile("pdftools-api-credentials.json")
.build();
The private key file is referenced in that .json.
Copy link to clipboard
Copied
@Joel_Geraci I tried the same, did not work for me last time because, I was not passing the path to the file properly. Now its working fine.
And this is what I did:
// Initial adobeClientCredentials, create credentials instance.
ClassLoader classLoader = this.getClass().getClassLoader();
String file = classLoader.getResource("credentials.json").getFile();
log.info("File Path: {}", file);
Credentials adobeClientCredentials = Credentials.serviceAccountCredentialsBuilder()
.fromFile(file)
.build();
Thank you !
I will let you guys know if I see any issues with this.