sslcert
2021-04-16 23:01:46 Author: github.com(查看原文) 阅读量:44 收藏

This library generate a new tlsconfig usable within go standard library configured with a self-signed certificate generated on the fly. Example:

package main

import (
	"log"
	"net/http"

	"github.com/projectdiscovery/sslcert"
)

func main() {
	tlsOptions := sslcert.DefaultOptions
	tlsOptions.Host = "test"
	tlsConfig, err := sslcert.NewTLSConfig(tlsOptions)
	if err != nil {
		log.Fatal(err)
	}
	server := &http.Server{
		TLSConfig: tlsConfig,
	}

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Hello World"))
	})

	if err := server.ListenAndServeTLS("", ""); err != nil {
		log.Fatal(err)
	}
}

文章来源: https://github.com/projectdiscovery/sslcert
如有侵权请联系:admin#unsafe.sh