Skip to content

Commit 6025848

Browse files
committed
Supply a certificate selection callback delegate,
so the client can select the particular cert in the collection to send to server. If this is not done, the certificate is null, and is never sent
1 parent 00369a1 commit 6025848

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/client/api/SslHelper.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,22 @@ namespace RabbitMQ.Client
7171
public class SslHelper
7272
{
7373

74+
static X509Certificate CertificateSelectionCallback(object sender,
75+
string targetHost,
76+
X509CertificateCollection localCertificates,
77+
X509Certificate remoteCertificate,
78+
string[] acceptableIssuers)
79+
{
80+
return localCertificates[0];
81+
}
82+
7483
///<summary>Upgrade a Tcp stream to an Ssl stream using the SSL options
7584
///provided</summary>
7685
public static Stream TcpUpgrade(Stream tcpStream, SslOption sslOption)
7786
{
78-
SslStream sslStream = new SslStream(tcpStream, false);
87+
SslStream sslStream = new SslStream(tcpStream, false,
88+
null,
89+
new LocalCertificateSelectionCallback(CertificateSelectionCallback));
7990

8091
sslStream.AuthenticateAsClient(sslOption.ServerName,
8192
sslOption.Certs,

0 commit comments

Comments
 (0)