1. Timothy Beck
  2. PowerBuilder
  3. Wednesday, 1 April 2020 19:45 PM UTC

Hi!

I'm attempting to connect to an internal .net Web Service using a certificate file.  I see that the old SoapConnection object had the SetClientCertificateFile method, but can't find the same (or similar) method in the RESTClient or HTTPClient.  Does anyone know how to pass a certificate to a Web Service using HTTP or REST?

Thanks!

 

Gregory Rusak Accepted Answer Pending Moderation
  1. Tuesday, 9 June 2020 18:16 PM UTC
  2. PowerBuilder
  3. # 1

Hello Appeon,

We too are needing to use SSL certificates with the HttpClient. Is the SetClientCertificateFile method being planned for a future release of PowerBuilder?

Thanks in advance.

Greg

Comment
  1. Mark Lee @Appeon
  2. Wednesday, 10 June 2020 08:21 AM UTC
Hi Gregory,

We plan to implement this feature in PB 2019 R3. However, I can’t guarantee it because this plan might be changed due to some additional requirements.

Thanks for your understanding.

Regards,
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Tuesday, 19 May 2020 16:41 PM UTC
  2. PowerBuilder
  3. # 2

I've never tried to pass a certificate, but if you can do it in SOAPUI or Postman, just trap the request using Fiddler or similar monitoring tool, then recreate it exactly with the HTTPClient.  I don't see why it wouldn't work.

Comment
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Thursday, 2 April 2020 03:26 AM UTC
  2. PowerBuilder
  3. # 3

Hi Timothy,

Thanks for reporting this problem.

Currently neither the HTTPClient object nor the RESTClient object supports the SetClientCertificateFile method (or a similar method) in PB 2017 or PB 2019.

But I will record it as a new enhancement / requirement request and will transfer it to our product team for consideration.

Regards,

Comment
  1. Timothy Beck
  2. Thursday, 2 April 2020 14:04 PM UTC
Mark,



Thanks! Do those methods (SetOptions and SetClientCertificateFile) modify the request header? Essentially, what I'm attempting to do is something along these lines in PB Classic:



public static X509Certificate2 GetClientCertificate()

{

var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);

string certCode = ConfigurationManager.AppSettings["certCode"].ToString();

X509Certificate2Collection certificatesFound;



try

{

store.Open(OpenFlags.ReadOnly);

//Specify the SPID certficate serial number to intiate the certificate

certificatesFound = store.Certificates.Find(X509FindType.FindBySerialNumber, certCode, true);



store.Close();



if (certificatesFound == null || certificatesFound.Count == 0)

{

throw new InvalidOperationException("Could not find a certificate!");

}

}

catch (Exception ex)

{

throw ex;

}

finally

{

if (store != null)

store.Close();

}

return certificatesFound[0];

}

  1. Helpful
  1. Mark Lee @Appeon
  2. Wednesday, 8 April 2020 03:16 AM UTC
Hi Timothy,



1. I suggest you upgrade your PB to PB 2019 R2 Build 2323 and use the new module of .NET DLL Importer. You can compile the code as a C# simple class to a DLL file and then import it to PB to pass the same function. You can find it in the local Help documentation and how to invoke it.

https://docs.appeon.com/appeon_online_help/pb2019r2/application_techniques/ch20s02.html



Note: currently some complex C# classes do not support it. You can refer to the below link:

https://docs.appeon.com/appeon_online_help/pb2019r2/application_techniques/ch20s01.html



2. You can also refer to the following link and see how another customer resolves this problem.

https://community.appeon.com/index.php/qna/q-a/call-rest-web-service-with-certificate?limitstart=0#reply-9854



Regards,
  1. Helpful
  1. Marco Meoni
  2. Tuesday, 9 June 2020 20:57 PM UTC
Hi Mark,

the link you posted refers to a 3rd party library and marks that library as accepted solution.

Nothing against that, Chilkat is a very good set of API and I too use it sometimes.

But I think a solution in this forum should be a a little bit more creative than just purchasing an external tool.



I like the idea of using .NET DLL importer. In that way it is possibile to use System.Net.HttpWebRequest and its ClientCertificates.Add() API for passing the certificate file.

A temporary solution until HTTPClient will provide built-in certificate support. :-)

Best,

.m
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.