Here is an example running server with TLS package main import ( "net/http" "log" ) func HelloServer(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "text/plain") w.Write([]byte("This is an example server.\n")) } func main() { http.HandleFunc("/hello", HelloServer) err := http.ListenAndServeTLS(":443", "server.crt", "server.key", nil) if err != nil { log.Fatal("ListenAndServe: ", err) } }
so in http package there is "ListenAndServeTLS" which can be used to run the server with TLS enabled. Hope that helps On Wed, Jun 3, 2020 at 2:20 PM 'Wesley Peng' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Hello, > > How do I program with SSL to make a server listen on specific port which > accepts SSL transfer only? > > Is there any guide for this since I have no experience on SSL socket > programming. > > Thanks. > > Wesley Peng > wesleyp...@aol.com > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/1690752345.1320667.1591168756241%40mail.yahoo.com > <https://groups.google.com/d/msgid/golang-nuts/1690752345.1320667.1591168756241%40mail.yahoo.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2Bp%2BMUenJBMsZHQ-hajr1b7Leq6vGLcAJ%3DJ_vNObj9NNEsV0aw%40mail.gmail.com.