Tag: golang

Key pinning in Golang

Jun 13, 2016 2 min.

Key pinning is a technique that can protect clients from rogue or compromised certificate authorities [1, 2, 3]. If you have control over the client and the server, you can bake the server’s public key into the client and bypass (or supplement) trust in certificate authorities. Many mobile applications on iOS and Android do this using these libraries: AFNetworking TrustKit AndroidPinning The Chrome and Firefox web browsers also allow pinning with pre-loaded pins and support of the HTTP Public Key Pinning (HPKP) protocol.

Golang range and pointers

Mar 18, 2015 3 min.

I’ve encountered bugs using pointers inside a range loop twice in the past few weeks. It seems like an easy/common mistake that is worth sharing. an example In this example a producer tries to pass pointers across a channel to a consumer. package main import "fmt" func main() { input := [5]int{1, 2, 3, 4, 5} c := make(chan *int, 0) // producer go func() { for _, val := range input { c <- &val } close(c) }() // consumer for val := range c { fmt.