public void Listen(string port, string identityHint, byte[] psk) { this.identityHint = identityHint; this.psk = psk; IntPtr tls; OpenSSL.OpenSSLCheck((tls = OpenSSL.TLSv1_2_server_method()) != IntPtr.Zero, "TLS_server_method"); OpenSSL.OpenSSLCheck((ctx = OpenSSL.SSL_CTX_new(tls)) != IntPtr.Zero, "SSL_CTX_new"); IntPtr ssl_bio; OpenSSL.OpenSSLCheck((ssl_bio = OpenSSL.BIO_new_ssl(ctx, 0)) != IntPtr.Zero, "BIO_new_ssl"); OpenSSL.OpenSSLCheck((in_bio = OpenSSL.BIO_new_accept(port)) != IntPtr.Zero, "BIO_new_accept"); OpenSSL.BIO_set_accept_bios(in_bio, ssl_bio); OpenSSL.OpenSSLCheck(OpenSSL.BIO_do_handshake(in_bio) == 1, "BIO_do_handshake"); // first call sets up the accept socket, subsequent get the connections }