From ae5d23d1c5af0d0ba0172269f117a32b79fa667b Mon Sep 17 00:00:00 2001 From: Savitha Date: Wed, 10 Aug 2022 20:03:26 +0530 Subject: [PATCH 1/2] To support api secret key to take input as string. --- .../HttpSigningConfiguration.mustache | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/HttpSigningConfiguration.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/HttpSigningConfiguration.mustache index 58a961b5da3c..6b773b8d596a 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/HttpSigningConfiguration.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/HttpSigningConfiguration.mustache @@ -317,14 +317,18 @@ namespace {{packageName}}.Client /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -422,11 +426,15 @@ namespace {{packageName}}.Client bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -717,9 +725,16 @@ namespace {{packageName}}.Client /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -729,7 +744,6 @@ namespace {{packageName}}.Client //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -743,7 +757,7 @@ namespace {{packageName}}.Client } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; } From cd0ee9b85ed32ecf39ff1b5235961487bade1a14 Mon Sep 17 00:00:00 2001 From: Savitha M R Date: Thu, 25 Aug 2022 15:23:24 +0530 Subject: [PATCH 2/2] To support Secret API key input as string --- .../Client/HttpSigningConfiguration.cs | 34 +++++++++++++------ .../Client/HttpSigningConfiguration.cs | 34 +++++++++++++------ .../Client/HttpSigningConfiguration.cs | 34 +++++++++++++------ .../Client/HttpSigningConfiguration.cs | 34 +++++++++++++------ .../Client/HttpSigningConfiguration.cs | 34 +++++++++++++------ .../Client/HttpSigningConfiguration.cs | 34 +++++++++++++------ 6 files changed, 144 insertions(+), 60 deletions(-) diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 6a8f9c8dc016..0b3e867d0f42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -325,14 +325,18 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -430,11 +434,15 @@ private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, Secu bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -725,9 +733,16 @@ private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -737,7 +752,6 @@ private PrivateKeyType GetKeyType(string keyFilePath) //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -751,7 +765,7 @@ private PrivateKeyType GetKeyType(string keyFilePath) } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 6a8f9c8dc016..0b3e867d0f42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -325,14 +325,18 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -430,11 +434,15 @@ private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, Secu bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -725,9 +733,16 @@ private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -737,7 +752,6 @@ private PrivateKeyType GetKeyType(string keyFilePath) //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -751,7 +765,7 @@ private PrivateKeyType GetKeyType(string keyFilePath) } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 6a8f9c8dc016..0b3e867d0f42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net47/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -325,14 +325,18 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -430,11 +434,15 @@ private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, Secu bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -725,9 +733,16 @@ private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -737,7 +752,6 @@ private PrivateKeyType GetKeyType(string keyFilePath) //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -751,7 +765,7 @@ private PrivateKeyType GetKeyType(string keyFilePath) } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 6a8f9c8dc016..0b3e867d0f42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-net5.0/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -325,14 +325,18 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -430,11 +434,15 @@ private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, Secu bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -725,9 +733,16 @@ private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -737,7 +752,6 @@ private PrivateKeyType GetKeyType(string keyFilePath) //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -751,7 +765,7 @@ private PrivateKeyType GetKeyType(string keyFilePath) } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 6a8f9c8dc016..0b3e867d0f42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -325,14 +325,18 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -430,11 +434,15 @@ private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, Secu bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -725,9 +733,16 @@ private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -737,7 +752,6 @@ private PrivateKeyType GetKeyType(string keyFilePath) //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -751,7 +765,7 @@ private PrivateKeyType GetKeyType(string keyFilePath) } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; } diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs index 6a8f9c8dc016..0b3e867d0f42 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClientCore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs @@ -325,14 +325,18 @@ private string GetRSASignature(byte[] stringToSign) /// ECDSA signature private string GetECDSASignature(byte[] dataToSign) { - if (!File.Exists(KeyFilePath)) + string keyStr = string.Empty; + if (File.Exists(KeyFilePath)) { - throw new Exception("key file path does not exist."); + keyStr = File.ReadAllText(KeyFilePath); + } + else + { + keyStr = KeyFilePath; } const string ecKeyHeader = "-----BEGIN EC PRIVATE KEY-----"; const string ecKeyFooter = "-----END EC PRIVATE KEY-----"; - var keyStr = File.ReadAllText(KeyFilePath); var ecKeyBase64String = keyStr.Replace(ecKeyHeader, "").Replace(ecKeyFooter, "").Trim(); var keyBytes = System.Convert.FromBase64String(ecKeyBase64String); var ecdsa = ECDsa.Create(); @@ -430,11 +434,15 @@ private RSACryptoServiceProvider GetRSAProviderFromPemFile(string pemfile, Secu bool isPrivateKeyFile = true; byte[] pemkey = null; - if (!File.Exists(pemfile)) + string pemstr = string.Empty; + if (File.Exists(pemfile)) + { + pemstr = File.ReadAllText(pemfile).Trim(); + } + else { - throw new Exception("private key file does not exist."); + pemstr = pemfile; } - string pemstr = File.ReadAllText(pemfile).Trim(); if (pemstr.StartsWith(pempubheader) && pemstr.EndsWith(pempubfooter)) { @@ -725,9 +733,16 @@ private byte[] DecryptKey(byte[] cipherData, byte[] desKey, byte[] IV) /// Private Key Type private PrivateKeyType GetKeyType(string keyFilePath) { - if (!File.Exists(keyFilePath)) + string[] key = null; + + if (File.Exists(keyFilePath)) + { + key = File.ReadAllLines(keyFilePath); + } + else { - throw new Exception("Key file path does not exist."); + // The ApiKeyFilePath is passed as string + key = new string[] { keyFilePath }; } const string ecPrivateKeyHeader = "BEGIN EC PRIVATE KEY"; @@ -737,7 +752,6 @@ private PrivateKeyType GetKeyType(string keyFilePath) //var pkcs8Header = "BEGIN PRIVATE KEY"; //var pkcs8Footer = "END PRIVATE KEY"; PrivateKeyType keyType; - var key = File.ReadAllLines(keyFilePath); if (key[0].Contains(rsaPrivateKeyHeader) && key[key.Length - 1].ToString().Contains(rsaPrivateFooter)) @@ -751,7 +765,7 @@ private PrivateKeyType GetKeyType(string keyFilePath) } else { - throw new Exception("Either the key is invalid or key is not supported"); + throw new Exception("The key file path does not exist or key is invalid or key is not supported"); } return keyType; }