After investigation, we found that cipher suites can only be specified in .NET 5 and must be in Linux or macOS.
If you use Linux or macOS with OpenSSL 1.1.1 or later, you can initialize an instance of the CipherSuitesPolicy class and use it like this:
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
stream.AuthenticateAsClient("*", x509Certificate2Collection, sslProtocol, sslCertRevocationCheck);
}
else
{
//stream.AuthenticateAsClient("*", x509Certificate2Collection, sslProtocol, sslCertRevocationCheck);
var sslClientOptions = new SslClientAuthenticationOptions()
{
CertificateRevocationCheckMode = sslCertRevocationCheck ? X509RevocationMode.Offline : X509RevocationMode.NoCheck,
ClientCertificates = x509Certificate2Collection,
EnabledSslProtocols = sslProtocol,
TargetHost = "*",
RemoteCertificateValidationCallback = ClientValidatingServerCertificate,
LocalCertificateSelectionCallback = FixClientCertificate,
//Initialize an instance of the CipherSuitesPolicy class.
CipherSuitesPolicy = new CipherSuitesPolicy(new List<TlsCipherSuite>() { Enum.Parse<TlsCipherSuite>(cipherSpec) })
};
TrText(method, $"Setting Cipher for AuthenticateAsClient {string.Join(':', sslClientOptions.CipherSuitesPolicy.AllowedCipherSuites)}");
stream.AuthenticateAsClient(sslClientOptions);
}
Related documents and posts for reference:
CipherSuitesPolicy Class
TlsCipherSuite Enum
How to force CipherSpec to specific value connecting to IBM MQ from RHEL using .net core. Get rid of CompCode: 2 Reason: 2059
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hi Timon,
We want to use 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384' cipher suite preferably for putting the file and getting the file from the device.