4 ms·
https is quite straightforwards in Go; the most direct means [1] essentially adds two parameters to http.ListenAndServe to supply paths to your cert and key fil
by swdunlop 14y ago
https is quite straightforwards in Go; the most direct means [1] essentially adds two parameters to http.ListenAndServe to supply paths to your cert and key file. The more flexible indirect ones involve either providing a TLS config [2] or using the crypto/tls package to create a TLS listener [3]. It comes down to which abstraction level works for your configuration.
Due to Go's pervasive use of io.Writer / io.Reader / net.Conn interfaces, once you have the problem of loading keys sorted, everything else is the same as writing a plain old TCP/IP listener. Configuring TLS will always be a pain -- decades, committees and broken implementations have seen to that.
As for actually verifying passwords and session integrity, Go's crypto packages are also pretty straightforwards and composable. The crypto/hmac [4] package is easily combined with various implementations of hash.Hash. In exchange for this simplicity, though, Go gives you plenty of opportunity to emulate LinkedIn and blow your own foot off, forgetting salt and common sense. There are plenty of higher level packages that offer to do it for you. (Blow your foot off, or hash your passwords -- I recommend reading implementations to decide which. :))
Also of interest when dealing with writing webapps in Go, the database/sql [5] package is an important abstraction. Since it is a more recent package, it often doesn't show up in google searches for sqlite, postgres, etc. This can give an impression that Go's database support is fragmented.
1 -- http://golang.org/pkg/net/http/#ListenAndServeTLS http://golang.org/pkg/net/http/#ListenAndServeTLS
2 -- http://golang.org/pkg/net/http/#Transport http://golang.org/pkg/net/http/#Transport
3 -- http://golang.org/pkg/crypto/tls/#Listener http://golang.org/pkg/crypto/tls/#Listener
4 -- http://golang.org/pkg/crypto/hmac http://golang.org/pkg/crypto/hmac
5 -- http://golang.org/pkg/database/sql http://golang.org/pkg/database/sql
- stewie2 14y agoThank you very much for the answers!