Releases: mdelapenya/tlscert
v0.1.0
What's Changed
The package exposes two functions and two types: SelfSigned
and SelfSignedFromRequest
, and Request
and Certificate
.
- The
Request
type is used to specify the parameters for the certificate generation. - The
Certificate
type is used to store the generated certificate and key, including the paths to the files on disk. - The
SelfSigned
function generates a self-signed certificate and returns it as aCertificate
value. This function only receives the host name for the certificate. - The
SelfSignedFromRequest
function generates a self-signed certificate based on the parameters in aRequest
value.
Therefore, it's possible to issue a self-signed certificate with a custom host name, and save it to disk, if needed, or to issue a certificate based on a parent certificate, which is useful for generating client certificates.
The Request
struct also provides a ParentDir
option that can be used to save the generated certificate to disk as a PEM file.
The Certificate
struct provides a Transport
method, which returns a pointer to a http.Transport
that can be used to perform HTTP requests using the generated certificate; and a TLSConfig
method, which returns a pointer to a tls.Config
. The Transport
method internally uses the TLSConfig
method.