コード例 #1
0
/* Make the connection */
func connect(conn bio.BIO) error {
	if bio.BIO_do_connect(conn) != 1 {
		return errors.New("Unable to connect to SSL destination")
	}

	if bio.BIO_do_handshake(conn) != 1 {
		return errors.New("Unable to complete SSL handshake")
	}

	return nil
}
コード例 #2
0
				host = "www.random.org"
				hostport = "www.random.org:443"

				/* Setup the connect BIO, since we're a client */
				conn = bio.BIO_new_ssl_connect(ctx)
				Expect(conn).NotTo(BeNil())
				Expect(bio.BIO_set_conn_hostname(conn, hostport)).To(BeEquivalentTo(1))
				Expect(bio.BIO_get_conn_hostname(conn)).To(Equal(hostport))

				/* Setup SSL */
				Expect(bio.BIO_get_ssl(conn, sslInst)).To(BeEquivalentTo(1))
				ciphers := "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MD5:!RC4"
				Expect(SSL_set_cipher_list(sslInst, ciphers)).To(Equal(1))
				Expect(SSL_set_tlsext_host_name(sslInst, host)).To(BeEquivalentTo(1))
				/* Make the connection */
				Expect(bio.BIO_do_connect(conn)).To(BeEquivalentTo(1))
			})

			// Expect(crypto.BIO_do_handshake(conn.(crypto.BIO))).To(BeEquivalentTo(1))
			/*flags := SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION
			  SSL_CTX_set_options(ctx, flags)
			  Expect(host).To(Equal(1))
			  //port := BIO_set_conn_port(web, 443)
			  BIO_get_ssl(web, &ssl)
			  const PREFERRED_CIPHERS = "HIGH:!aNULL:!kRSA:!PSK:!SRP:!MDS:!RC4"
			  cipher := SSL_set_cipher_list(ssl, PREFERRED_CIPHERS)
			  Expect(cipher).To(Equal(1)) */
		})
	})
	/* Cannot fail ??? */