Thursday 4 April 2024

load cert and pem go

 https://stackoverflow.com/questions/38582937/how-to-create-a-tls-client-with-ca-certificates-in-go

flag:

https://pkg.go.dev/flag


import "flag"
var nFlag = flag.Int("n", 1234, "help message for flag n")
var (
    certFile = flag.String("cert", "someCertFile", "A PEM eoncoded certificate file.")
    keyFile  = flag.String("key", "someKeyFile", "A PEM encoded private key file.")
    caFile   = flag.String("CA", "someCertCAFile", "A PEM eoncoded CA's certificate file.")
)

func main() {
    flag.Parse()

    // Load client cert
    cert, err := tls.LoadX509KeyPair(*certFile, *keyFile)
    if err != nil {
        log.Fatal(err)
    }

No comments:

Post a Comment