summaryrefslogtreecommitdiff
path: root/contrib/tlsauth/auth.go
blob: ff8529bd7e52fde5ef6993f615e6dcc3f57c6929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package tlsauth

import (
	"crypto/x509"

	sr "tildegit.org/tjp/sliderule"
)

// Identity returns the client certificate for the request or nil if there is none.
func Identity(request *sr.Request) *x509.Certificate {
	if request.TLSState == nil || len(request.TLSState.PeerCertificates) == 0 {
		return nil
	}
	return request.TLSState.PeerCertificates[0]
}