title: Check fingerprints of server SSL/TLS certificates in http.NewRequest
body: <p>How can I check the fingerprints of the server SSL/TLS certificates during a http request in golang?</p>
  
  <p>This <a href="https://github.com/figo-connect/ruby-figo/blob/c8264fcd778f47e517d8e1675337fc4e29a2b6b5/lib/figo.rb#L69" rel="noreferrer">ruby code</a> shows what I want to do in Go:</p>
  
  <pre><code>  @verify_callback = proc do |preverify_ok, store_context|
      if preverify_ok and store_context.error == 0
        certificate = OpenSSL::X509::Certificate.new(store_context.chain[0])
        fingerprint = Digest::SHA1.hexdigest(certificate.to_der).upcase.scan(/../).join(":")
        $valid_fingerprints.include?(fingerprint)
      else
        false
      end
    end
  </code></pre>