1
0
mirror of https://github.com/libp2p/go-openssl.git synced 2025-04-25 17:50:23 +08:00

Add SSL_get_cipher_name(...)

This commit is contained in:
Andrew Brampton 2014-10-07 20:41:21 -07:00
parent 10dbddf4e6
commit 87a7e0f1c3

12
conn.go
View File

@ -28,6 +28,9 @@ package openssl
// long SSL_set_tlsext_host_name_not_a_macro(SSL *ssl, const char *name) {
// return SSL_set_tlsext_host_name(ssl, name);
// }
// const char * SSL_get_cipher_name_not_a_macro(const SSL *ssl) {
// return SSL_get_cipher_name(ssl);
// }
import "C"
import (
@ -144,6 +147,15 @@ func Server(conn net.Conn, ctx *Ctx) (*Conn, error) {
return c, nil
}
func (c *Conn) CurrentCipher() (string, error) {
p := C.SSL_get_cipher_name_not_a_macro(c.ssl)
if p == nil {
return "", errors.New("Session not established")
}
return C.GoString(p), nil
}
func (c *Conn) fillInputBuffer() error {
for {
n, err := c.into_ssl.ReadFromOnce(c.conn)