From 84fb87afa56360f6128a9f5948cb41311539c94f Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Sat, 18 Feb 2017 23:35:38 -0800 Subject: [PATCH] Add TLSConnectionState() method to forked ldap package --- starttls/ldap/conn.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/starttls/ldap/conn.go b/starttls/ldap/conn.go index e701a9b..b2b47d2 100644 --- a/starttls/ldap/conn.go +++ b/starttls/ldap/conn.go @@ -264,6 +264,15 @@ func (l *Conn) StartTLS(config *tls.Config) error { return nil } +// TLSConnectionState returns the current connection's TLS ConnectionState, or an error if not TLS. +func (l *Conn) TLSConnectionState() (*tls.ConnectionState, error) { + if !l.isTLS { + return nil, errors.New("ldap: Cannot get TLS Connection State for non-TLS connection") + } + state := l.conn.(*tls.Conn).ConnectionState() + return &state, nil +} + func (l *Conn) sendMessage(packet *ber.Packet) (*messageContext, error) { return l.sendMessageWithFlags(packet, 0) }