{"title":"HttpClient.AddCertificate(SecretText [, SecretText]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/httpclient/httpclient-addcertificate-secrettext-secrettext-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/httpclient/httpclient-addcertificate-secrettext-secrettext-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/httpclient/httpclient-addcertificate-secrettext-secrettext-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Adds a certificate as a SecretText to the HttpClient class.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":121,"chars":97},{"level":2,"title":"Parameters","slug":"parameters","at":218,"chars":277},{"level":2,"title":"Example","slug":"example","at":495,"chars":627},{"level":2,"title":"Remarks","slug":"remarks","at":1122,"chars":1978},{"level":2,"title":"Related information","slug":"related-information","at":3100,"chars":138}],"text":"> Version: _Available or changed with runtime version 12.0._\nAdds a certificate as a SecretText to the HttpClient class.\n## Syntax\n```al\n HttpClient.AddCertificate(Certificate: SecretText [, Password: SecretText])\n```\n## Parameters\nHttpClient\nType: httpclient-data-type\nAn instance of the httpclient-data-type data type.\nCertificate\nType: ../secrettext/secrettext-data-type\nThe Base64 encoded certificate.\n*[Optional] Password*\nType: ../secrettext/secrettext-data-type\nThe certificate password.\n## Example\nThe following example shows how to add a certificate to the HttpClient data type.\n```al\n// This code shows how to use certificates with HttpClient\nprocedure AddCertificateToHttpClient(var HttpClient: HttpClient; CertificateCode: Text[6])\nvar\n    IsolatedCertificate: Record \"Isolated Certificate\";\n    CertificateManagement: Codeunit \"Certificate Management\";\nbegin\n    if not IsolatedCertificate.Get(CertificateCode) then\n        exit;\n    HttpClient.AddCertificate(\n        CertificateManagement.GetCertAsBase64String(IsolatedCertificate),\n        CertificateManagement.GetPassword(IsolatedCertificate));\nend;\n```\n## Remarks\nThe certificate must be Base64 encoded. Use a certificate that's intended for client authentication.\nWith the AddCertificate method you set the certificates that you want to be associated to the request of the HTTP client connection. These certificates are used only to authenticate the client. They don't configure or validate the server certificate that the external endpoint presents.\nThe system caches SSL sessions as they are created and attempts to reuse a cached session for a new request, if possible. When attempting to reuse an SSL session, it uses the first certificate that was added or tries to reuse an anonymous session if no certificates have been specified.\n> IMPORTANT\n> The certificate must use one of the supported cipher suites; otherwise, outgoing web service calls will fail with a security exception. See ../../devenv-supported-cipher-suites.\n> In Business Central online, certificates used with HttpClient, including client certificates added with the AddCertificate method, must be issued by a trusted public certification authority (CA). Self-signed certificates and certificates issued by private or internal CAs aren't trusted by default and can cause HTTP calls to fail. To help ensure successful and secure communication, use certificates that are part of a standard trust chain anchored in a well-known public CA.\n> IMPORTANT\n> In Business Central versions 22 (2023 release wave 1) and later, certificates must include the following information:\n > If KeyUsage is defined, specify DigitalSignature.\n > If ExtendedKeyUsage is defined, specify ClientAuthentication.\n> This is due to different behavior between .NET Core and .NET Framework.\n> When making an outbound http call to an external endpoint, if you receive a 403 response (external endpoint required a certificate), and your code _does_ have a HttpClient.AddCertificate, check the version of the Business Central platform and the requirements for KeyUsage and ExtendedKeyUsage.\n## Related information\nhttpclient-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}