Closed gagyn closed 1 year ago
Hi @gagyn Thanks for reporting this. I tried to reproduce this by creating a new JWT Quickstart for C# but I was not able to reproduce this. Do you have a code snippet for where you are requesting a JWT Token so I can take a look?
Hi, I'm getting System.Exception: 'Unexpected PEM type'
exception for this code:
var privateKeyStream = File.OpenRead("docusign.key");
var token = docuSignClient.RequestJWTUserToken(docuSignSettings.IntegrationKey, docuSignSettings.UserId,
docuSignSettings.OAuthUrl, privateKeyStream, expiresInHours: 1);
I've ensured the privateKeyStream contains correct file content. The variables in docuSignSettings are also correct, as I'm using them with the RequestJWTUserToken overload which takes privateKey as byte[] and it's working fine then.
Hello @gagyn - our team is going to be taking a look into the issue shortly. Thanks for reporting the issue!
Just an FYI @gagyn, this change should be included in the 6.4.0 release which just went out in the past 24 hours. I'll close the issue, but feel free to re-open or create a new issue if the issue persists.
https://github.com/docusign/docusign-esign-csharp-client/blob/6c1bd9a58d59c5f8a507f94eedacf5015d6d8a04/sdk/src/DocuSign.eSign/Client/DocuSignClient.cs#L889
The mentioned above overload of RequestJWTUserToken method, which takes private key parameter as Stream object is using .Peek() method. The consequence of this way is StreamReader reading first 1024 bytes from privateKeyStream.
byte[] privateKeyBytes = ReadAsBytes(privateKeyStream);
- line is returning only the rest of the bytes left.In this way, the mentioned RequestJWTUserToken overload is useless and always throwing exception.