Hi all
How do I find and use certificates in AL code for Business Central Cloud?
In my AL code Extension for Business Central Cloud, I'm trying to communicate with a third-party web service that requires a mutual authentication via TSL.
Here is what I have:
procedure InvokeWebOp(ContentText: Text)
var
Content: HttpContent;
Headers: HttpHeaders;
Client: HttpClient;
Response: HttpResponseMessage;
ErrorLabel001: Label 'The call to the web service failed.';
TempText: Text;
Cert: Text;
begin
Content.WriteFrom(ContentText);
Content.GetHeaders(Headers);
Headers.Remove('Content-Type');
Headers.Add('Content-Type', 'application/json');
// cert = ???
Client.AddCertificate(cert);
if not Client.Get('https://[service]/api/Values', Response) then
Error(ErrorLabel001);
// Check if successful
if not Response.IsSuccessStatusCode then begin
Message('Call failed' + Response.ReasonPhrase);
end
else begin
Response.Content.ReadAs(TempText);
Message('Call to Values returned: ' + TempText);
end;
end;
I'm not sure if I'm on the right track but so far I found that I can upload my certificate using the Business Central Web Client - Certificates page and set the access - user or company. However I can't find out how to lookup and use the certificate.
Any help is much appreciated.
Thorbjorn