I am not able to generate JWT using a password protected private key. I am getting following response:
{
"fault": {
"faultstring": "Failed to parse key: policy(Generate-JWT-Token) ",
"detail": {
"errorcode": "steps.jwt.KeyParsingFailed"
}
}
}
I am not sure if the policy is able to consume the password protected private key in this case. I might be missing something here. Please help.
Here is my setup
- I have generated PEM (password protected private key) using following command
openssl pkcs12 -in tokensigning.pfx -nocerts -out token-private-key.pem
Here is the encryption method details from PFX
openssl pkcs12 -info -in tokensigning.pfx -nooutPKCS7 Data
Output:
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2000
PKCS7 Encrypted data: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2000
Private Key
Bag Attributes
Microsoft Local Key set: <No Values>
localKeyID: 01 00 00 00
Microsoft CSP Name: Microsoft RSA SChannel Cryptographic Provider
friendlyName: some-friendly-name-16a8f7db122f
Key Attributes
X509v3 Key Usage: 10
-----BEGIN ENCRYPTED PRIVATE KEY-----
key data.......
-----END ENCRYPTED PRIVATE KEY-----
KeyValueMap Policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="KVM-GetTokenSigningPrivateKey" mapIdentifier="oauth-token-signing">
<Scope>environment</Scope>
<ExpiryTimeInSecs>15</ExpiryTimeInSecs>
<Get assignTo="private.private-key">
<Key>
<Parameter>privatekey</Parameter>
</Key>
</Get>
<Get assignTo="private.privatekey-password">
<Key>
<Parameter>privatekey-password</Parameter>
</Key>
</Get>
</KeyValueMapOperations>
Generate JWT policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<GenerateJWT name="Generate-JWT-Token">
<Algorithm>RS256</Algorithm>
<PrivateKey>
<Value ref="private.private-key"/>
<Password ref="private.privatekey-password"/>
<Id>unique-identifier-for-privatekey-here</Id>
</PrivateKey>
<Subject>ABCD</Subject>
<Issuer>urn://1a4b40567d5a</Issuer>
<Audience>urn://api.dev</Audience>
<ExpiresIn>60m</ExpiresIn>
<AdditionalClaims>
<Claim name="apigee-proxy" ref="apiproxy.name"/>
<Claim name="messageid" ref="messageid"/>
<Claim name="request-path" ref="request.path"/>
<Claim name="apigee-org" ref="organization.name"/>
<Claim name="apigee-env" ref="environment.name"/>
</AdditionalClaims>
<OutputVariable>output-jwt</OutputVariable>
</GenerateJWT>