This is a challenge at work: in order to talk with a QA service, I have to provide a certificate that makes F5 happy.

What is a x509 certificate and how it works

X.509 certificates are used in many Internet protocols, including TLS/SSL

x509 certificate signed by unknown authority

See this post on the reason and fix to this error.

Apply client certificate: crypto/tls

  • Serving HTTP with TLS: see this example from denji and this example from crypto/tls pkg
  • Calling HTTP with TLS: http.Transport is an implementation of RoundTripper that supports HTTP, HTTPS, and HTTP proxies (for either HTTP or HTTPS with CONNECT). To make a call to an HTTPS endpoint with self-provided key:
    1
    2
    3
    4
    5
    6
    tlsConfig := &tls.Config{
    Certificates: []tls.Certificate(cert),
    }
    tlsConfig.BuildNameToCertificate()
    transport := &http.Transport{TLSClientConfig: tlsConfig}
    client := &http.Client{Transport: transport}

Decode pfx file: pkcs12

pkcs12 is intended for decoding P12/PFX-stored certificates and keys for use with the crypto/tls package.