forked from loafle/openapi-generator-original
Fixed the HttpSigning issue for ECDSA key supplied as string. (#17459)
Co-authored-by: Aanisha Mishra <aanisha.mishra05@gmail.com> Co-authored-by: Vikrant Balyan (vvb) <vvb@cisco.com> Co-authored-by: Vikrant Balyan <vvb@users.noreply.github.com> Co-authored-by: Sebastien Rosset <serosset@cisco.com>
This commit is contained in:
@@ -110,14 +110,13 @@ namespace Org.OpenAPITools.Client
|
||||
const string HEADER_AUTHORIZATION = "Authorization";
|
||||
|
||||
//Read the api key from the file
|
||||
if(string.IsNullOrEmpty(this.KeyString))
|
||||
if(File.Exists(KeyFilePath))
|
||||
{
|
||||
this.KeyString = ReadApiKeyFromFile(KeyFilePath);
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(KeyString))
|
||||
else if(string.IsNullOrEmpty(KeyString))
|
||||
{
|
||||
throw new Exception("No API key has been provided.");
|
||||
throw new Exception("No API key has been provided. Supply it using either KeyFilePath or KeyString");
|
||||
}
|
||||
|
||||
//Hash table to store singed headers
|
||||
@@ -325,6 +324,10 @@ namespace Org.OpenAPITools.Client
|
||||
|
||||
private string GetRSASignature(byte[] stringToSign)
|
||||
{
|
||||
if (string.IsNullOrEmpty(KeyString))
|
||||
{
|
||||
throw new Exception("No API key has been provided.");
|
||||
}
|
||||
RSA rsa = GetRSAProviderFromPemFile(KeyString, KeyPassPhrase);
|
||||
if (SigningAlgorithm == "RSASSA-PSS")
|
||||
{
|
||||
@@ -412,6 +415,11 @@ namespace Org.OpenAPITools.Client
|
||||
|
||||
private RSACryptoServiceProvider GetRSAProviderFromPemFile(string keyString, SecureString keyPassPhrase = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(KeyString))
|
||||
{
|
||||
throw new Exception("No API key has been provided.");
|
||||
}
|
||||
|
||||
const string pempubheader = "-----BEGIN PUBLIC KEY-----";
|
||||
const string pempubfooter = "-----END PUBLIC KEY-----";
|
||||
bool isPrivateKeyFile = true;
|
||||
|
||||
Reference in New Issue
Block a user