Failed to parse key: policy during verifying JWT policy using a public key stored in KVM.

Hi,

@dino,

I am trying to verify a JWT using a public key stored in KVM, but its failing with the following error code:

"errorcode": "steps.jwt.KeyParsingFailed"

my trace error says "

error 'an invalid public key was provided'

The same public key works fine if I am using Assign message policy.

what's happening when I am using key stored in KVM is,

all the spaces are getting removed from the public key.

For ex:if the public key pem file contents is as shown below,

-----BEGIN PUBLIC KEY-----

foo boo

-----END PUBLIC KEY-----

I can see in my trace in phase details, that the public key is interpreted as shown below,

-----BEGIN PUBLIC KEY-----fooboo-----END PUBLIC KEY-----


Can you please help?

Solved Solved
0 7 2,468
1 ACCEPTED SOLUTION

sidd-harth
Participant V

Hi @Shruthi Ranganatha, I think this is happening as you are loading a multi-lined value in KVM, please have a look at below posts.

https://community.apigee.com/questions/58862/genarate-jwt-token-read-kvm-for-privatekey.html

View solution in original post

7 REPLIES 7

sidd-harth
Participant V

Hi @Shruthi Ranganatha, I think this is happening as you are loading a multi-lined value in KVM, please have a look at below posts.

https://community.apigee.com/questions/58862/genarate-jwt-token-read-kvm-for-privatekey.html

Yes, that's the first thing I thought of, as well.

The KVM UI has recently been updated (available in Edge SaaS only). Can you show the screenshot of the public key in the KVM UI ?

Hi Dino,Siddharth,

It working fine now after removing the index attribute.

Thanks for the quick help!

GREAT! Thanks for the note.

Hi !

Although removal of index attribute is working for private key. It ain't working for public key.

Please find the screenshot of my public key in KVM UI

and screenshot of my KVM policy attached below,policy.png

kvm.png

And here's the screenshot of error trace

trace.png

So , here's what I tried,

I tried to upload contents of my public.pem file to KVM via APIGEE management API for 'Create KVM for organization'.

I was able to create a key value pair via postman successfully.

loadkey.png

and here is the screenshot of my updated KVM policy

updatedkvmpolicy.png

But I am still facing the same issue! - 'an invalid public key was provided'

I am not understanding how to solve this.

Sorry for striking out the key values in a shabby way.

PS: Everything works fine if I use Assign message policy like I mentioned before:-(

Hi @Dino !

Although removal of index attribute is working for private key. It ain't working for public key.

Please find the screenshot of my public key in KVM UI

and screenshot of my KVM policy attached below,policy.png

kvm.png

And here's the screenshot of error trace

trace.png

So , here's what I tried,

I tried to upload contents of my public.pem file to KVM via APIGEE management API for 'Create KVM for organization'.

I was able to create a key value pair via postman successfully.

loadkey.png

and here is the screenshot of my updated KVM policy

updatedkvmpolicy.png

But I am still facing the same issue! - 'an invalid public key was provided'

I am not understanding how to solve this.

Sorry for striking out the key values in a shabby way.

PS: Everything works fine if I use Assign message policy like I mentioned before:-(

The KVM is finally working fine for me now after taking care of new line character in post request to create KVM for public key. I replaced new lines with '\n' to send public key in the request json.