Using Certificates on FHIR Client


#1

Hello Team,
i am new on FHIR and i am implementing a small .Net-Client to access our FHIR restful server.

I could successfully access the FHIR Test Server and get data of Patient resource.

But trying to connect to our local Server i am getting an error “… no protected SSL/TLS canal could be established …”

My questions are following:
Is it possible to bind a certificate on my Client?
Can i have any example code?

Thanks
Elie


#2

Hi Elie,

The fhir client has two events available OnBeforeRequest and OnAfterResponse that you can subscribe to. In these events you can manipulate the outgoing request so you can bind a certificate there!


#3

Hi,
thank you so much for your Feedback.
i will try to use These Events now to do my implementation.

Best regards


#4

Using the Events ‘OnBeforeRequest’ i was able to now connect to the Server implementing the following 2 things:

  1. pushed my certificate into my request
  2. set the SecurityProtocolType to Tls12, because my Server ist only supporting this protocol type

    //1.
    X509Certificate2 clientCert2 = getCertificate();
    if (clientCert2 != null)
    {
    e.RawRequest.ClientCertificates.Clear();
    e.RawRequest.ClientCertificates.Add(clientCert2);
    }


//2.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Thanks Ewut for the hint

Best regards,
Elie