Certificate error, Invalid provider type specified.
Hi, I am facing an issue with an inaccessible private key and the error "invalid provider type specified" while trying to establish connectivity with Solace using .NET. We have generated the certificates multiple times but are still stuck at this point.
After some investigation, we noticed that .NET and C have stricter restrictions on certificates compared to other languages, but we’re not sure what the specific cause of the problem is.
Has anyone else encountered this issue? Could it be related to how the certificates are generated, or is there something we might be missing in the configuration? Any insights would be greatly appreciated!
Note: we received cer file and generating pfx through windows certificate manager.
we suspected the issue with loading certificates.
So I tried these options.
1) clientCert = new X509Certificate2(certPath, certPassword, X509KeyStorageFlags.Exportable);
2) clientCert = new X509Certificate2("path/to/cert.pfx", "password", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
nothing worked. Could it be related to PFX ?
{
// Create session properties. get from config
SessionProperties sessionProps = new SessionProperties
{
Host = host,
VPNName = vpnName,
ReconnectRetries = paramReconnectRetries,
ConnectRetriesPerHost = paramConnectRetriesPerHost,
ReconnectRetriesWaitInMsecs = paramReconnectRetriesWaitInMsecs,
ConnectRetries = paramConnectRetriesPerHost,
ConnectTimeoutInMsecs = paramConnectTimeoutInMilliSecs,
ClientName = paramClientName,
SSLCipherSuites = null,
AuthenticationScheme = AuthenticationSchemes.CLIENT_CERTIFICATE,
SSLValidateCertificate = true,
SSLTrustStoreDir = truststoreDir,
SSLExcludedProtocols = "",
SSLClientCertificate = clientCert
};
}
24/09/24 14:35:49.265|1|0|Error|app| Exception while Initializing: Failed to access certficate field PrivateKey, cause: Invalid provider type specified. Parameter name: SSLClientCertificate
24/09/24 14:35:49.265|1|0|Error|app| Unable to initialized: Object reference not set to an instance of an object.
24/09/24 14:35:49.265|7|0|Info|app| OnStart: Trying to Start
24/09/24 14:35:49.265|7|0|Debug|app| Initiliazing...