https-go: github.com/rocketlaunchr/https-go Index | Files

package https

import "github.com/rocketlaunchr/https-go"

Index

Package Files

https.go options.go ssl_go113.go

func GenerateKeys Uses

func GenerateKeys(opts GenerateOptions) ([]byte, []byte, error)

GenerateKeys will return the public and private keys.

See https://github.com/denji/golang-tls and https://stackoverflow.com/questions/47857573/passing-certificate-and-key-as-string-to-listenandservetls/47857805

func Server Uses

func Server(port string, opts GenerateOptions) (*http.Server, error)

Server will create a self-signed https server.

Example:

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) })

opts := GenerateOptions{Host: "domain.com"}
httpServer, _ := Server("8080", opts)
log.Fatal(httpServer.ListenAndServeTLS("", ""))

type GenerateOptions Uses

type GenerateOptions struct {

    // Comma-separated hostnames and IPs to generate a certificate for.
    Host string

    // Creation date formatted as "Jan 1 15:04:05 2011".
    // Default is time.Now().
    ValidFrom string

    // Duration that certificate is valid for.
    // Default is 365*24*time.Hour.
    ValidFor time.Duration

    // Whether this cert should be its own Certificate Authority
    // Default is false.
    IsCA bool

    // Size of RSA key to generate. Ignored if ECDSACurve is set
    // Default is 2048.
    RSABits int

    // ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521
    // Default is "".
    ECDSACurve string

    // Generate an Ed25519 key
    // Default is false.
    ED25519Key bool
}

GenerateOptions is used to configure the keys.

Package https imports 17 packages (graph). Updated 2020-02-18. Refresh now. Tools for package owners.