ballerinaballerina-swan-lakeballerina-http

Configuring Endpoint Certificates in Ballerina: Supported Formats and Certificate Chain Integration


How can I properly configure the endpoint certificate in the Ballerina client secure socket? I'm particularly interested in understanding the supported certificate formats and whether Ballerina accommodates certificate chains.

As per the documentation, it accepts a TrustStore or a cert file. But there is no information about the supported certificate formats and the support for certificate chains.


Solution

  • In the context of Ballerina client secure socket configuration, you can provide the endpoint certificate in either KeyStore or cert file formats.

    Specifically:

    1. For public certificates, Ballerina supports cert and pem formats.

    2. When dealing with private keys, it's recommended to use the pkcs8 format. If your private key is currently in a different format, you can convert it to pkcs8 using the following command:

      openssl pkcs8 -topk8 -nocrypt -in pkcs1_key_file -out pkcs8_key.pem
      
    3. Keystores in the pkcs12 format, often denoted by a pfx extension, are also supported.

    Yes, Ballerina supports certificate chains.

    When configuring certificate chains:

    1. Arrange the certificates with the end-user certificate at the top of the file, followed by its issuer certificate, and so forth.
    2. If you're working with certificates issued by Certificate Authorities, concatenate the chained certificates. Ensure the end-user certificate appears before the issuer certificates.
    3. Importantly, avoid introducing newlines between the end-user certificate and the chained certificates. Concatenate this chain and place it at the end of the file.