Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "crypto/tls"
- func main() {
- cert, err := tls.LoadX509KeyPair("server.crt", "server.key")
- if err != nil {
- panic(err)
- }
- config := new(tls.Config)
- config.Certificates = []tls.Certificate{ cert }
- config.AuthenticateClient = true
- listener, err := tls.Listen("tcp", "127.0.0.1:8080", config)
- if err != nil {
- panic(err)
- }
- for {
- conn, err := listener.Accept()
- if err != nil {
- panic(err)
- }
- tlsConn := conn.(*tls.Conn)
- err = tlsConn.Handshake()
- if err != nil {
- println("Handshake failed:", err.Error())
- tlsConn.Close()
- continue
- }
- println("Handshake succeeded!")
- tlsConn.Close()
- }
- }
Add Comment
Please, Sign In to add comment