Skip to content

net.openssl

fn new_ssl_conn #

fn new_ssl_conn(config SSLConnectConfig) !&SSLConn

new_ssl_conn instance an new SSLCon struct

fn SSLError.from #

fn SSLError.from[W](input W) !SSLError

fn Select.from #

fn Select.from[W](input W) !Select

struct C.BIO #

@[typedef]
struct C.BIO {
}

struct C.SSL #

@[typedef]
struct C.SSL {
}

struct C.SSL_CTX #

@[typedef]
struct C.SSL_CTX {
}

struct C.SSL_METHOD #

@[typedef]
struct C.SSL_METHOD {
}

struct C.X509 #

@[typedef]
struct C.X509 {
}

struct SSLConn #

struct SSLConn {
pub:
	config SSLConnectConfig
pub mut:
	sslctx   &C.SSL_CTX = unsafe { nil }
	ssl      &C.SSL     = unsafe { nil }
	handle   int
	duration time.Duration

	owns_socket bool
	// last_write_sent reports the most recent write_ptr's progress for retry
	// decisions: 0 = provably nothing was sent (safe to replay), or -1 = the
	// count is indeterminate because a failed/retryable write may have already
	// flushed complete records to the peer (TLS cannot prove zero). On full
	// success it equals the bytes written.
	last_write_sent int
}

SSLConn is the current connection

fn (SSLConn) close #

fn (mut s SSLConn) close() !

close closes the ssl connection and does cleanup

fn (SSLConn) negotiated_alpn #

fn (s &SSLConn) negotiated_alpn() string

negotiated_alpn returns the ALPN protocol selected during the TLS handshake (e.g. 'h2' or 'http/1.1'), or an empty string if no protocol was negotiated.

fn (SSLConn) shutdown #

fn (mut s SSLConn) shutdown() !

shutdown closes the ssl connection and does cleanup

fn (SSLConn) connect #

fn (mut s SSLConn) connect(mut tcp_conn net.TcpConn, hostname string) !

connect to server using OpenSSL

fn (SSLConn) dial #

fn (mut s SSLConn) dial(hostname string, port int) !

dial opens an ssl connection on hostname:port

fn (SSLConn) read_timeout #

fn (s &SSLConn) read_timeout() time.Duration

read_timeout returns the current SSL read timeout.

fn (SSLConn) set_read_timeout #

fn (mut s SSLConn) set_read_timeout(timeout time.Duration)

set_read_timeout sets the read timeout used for subsequent SSL reads. A value of 0, or net.infinite_timeout means "wait forever".

fn (SSLConn) addr #

fn (s &SSLConn) addr() !net.Addr

addr retrieves the local ip address and port number for this connection

fn (SSLConn) peer_addr #

fn (s &SSLConn) peer_addr() !net.Addr

peer_addr retrieves the ip address and port number used by the peer

fn (SSLConn) socket_read_into_ptr #

fn (mut s SSLConn) socket_read_into_ptr(buf_ptr &u8, len int) !int

fn (SSLConn) read #

fn (mut s SSLConn) read(mut buffer []u8) !int

fn (SSLConn) write_ptr #

fn (mut s SSLConn) write_ptr(bytes &u8, len int) !int

write_ptr writes len bytes from bytes to the ssl connection

fn (SSLConn) write #

fn (mut s SSLConn) write(bytes []u8) !int

write writes data from bytes to the ssl connection

fn (SSLConn) write_string #

fn (mut s SSLConn) write_string(str string) !int

write_string writes a string to the ssl connection

struct SSLConnectConfig #

@[params]
struct SSLConnectConfig {
pub:
	verify   string // the path to a rootca.pem file, containing trusted CA certificate(s)
	cert     string // the path to a cert.pem file, containing client certificate(s) for the request
	cert_key string // the path to a key.pem file, containing private keys for the client certificate(s)
	validate bool   // set this to true, if you want to stop requests, when their certificates are found to be invalid

	in_memory_verification bool // if true, verify, cert, and cert_key are read from memory, not from a file

	alpn_protocols []string // the list of ALPN protocols to advertise, e.g. ['h2', 'http/1.1']; empty means no ALPN extension is sent
}