How to setup certificate for Client in Fellow-Oak Dicom?

257 views
Skip to first unread message

Daniele Gamba

unread,
Mar 28, 2019, 5:59:51 AM3/28/19
to Fellow Oak DICOM

Deak folks, I'm trying to setup a Dicom Client using the Fellow Oak Dicom library. I succesfully do all the queries, using the DicomClient class, as indicated in the github page https://github.com/fo-dicom/fo-dicom .

However, how can I specify a certificate to use for authenticating my client?

I found that this is how you usually do in C#, https://www.medo64.com/2014/09/client-authenticated-tls-in-c/ and I see that this is exactly what the Fo-Dicom library is doing. I can't find a way to specify my certificate though.

Daniele Gamba

unread,
Mar 29, 2019, 5:11:49 AM3/29/19
to Fellow Oak DICOM
Okay, I've solved by overriding the DesktopNetworkStream class where I just replaced, in the main constructor,

               ssl.AuthenticateAsClient(host)

with

               var trust = new X509Certificate2("serverCert.p12","myPwd");
               var key = new X509Certificate2("clientCert.p12","myPwd");
               var clientCertificateCollection = new X509CertificateCollection(new X509Certificate[] { trust,key });
                
               ssl.AuthenticateAsClient(host, clientCertificateCollection, SslProtocols.Tls12, false);



and I call it, instead of 

                client.Send(serverIp, serverPort, false, callingAET, calledAET);

with 

                var _networkStream = new DesktopNetworkStreamTls(serverIp, serverPort, true, true, true);
                client.Send(_networkStream, callingAET, calledAET, 5000);
Reply all
Reply to author
Forward
0 new messages