I have been working on this for forever now.
Need: Call "...oktapreview.com/oauth2/v1/token" to receive a token for use in future calls. I am able to do this with postman just fine, trying to do the same in Salesforce with Apex or .js via LWC
Basically, I need apex code that can create a JWT and sign it within Salesforce. As done here , JWT Token Exchange setup in Named Credentials for outbound callout , My issue with the above link is, the user references 'okta_cert' for the DevName of his cert, implying that he has uploaded a key for signing the JWT. The key I have for signing is a .pem file that I cannot seem to figure out how to get into salesforce for reference.
If I use the other Cryto.Sign(...) that uses a private key blob, I am getting many different issues related to encoding and decoding the key in base64.
I am able to get a result if I only use the body of the .pem ('MIIEvgIBADANBgk.....'), but the result is wrong. If I try the same with the whole .pem ('-----BEGIN RSA PRIVATE KEY-----\nMIIEv....) then I get a lot of Invalid Crypto Key or Unrecognized base64 character during encoding decoding.
Somebody help pls.