// Write writes n bytes from b onto the connection.
// Write returns the number of bytes written and any error that occurred.
func (h HTTPSConn) Write(b []byte) (n int, err error) {
	ret := bio.BIO_write(h.sslBio, string(b), len(b))
	if ret != len(b) {
		return ret, fmt.Errorf("SSL socket write failed; only %d bytes written out of %d", ret, len(b))
	}

	return ret, nil
}
	var x X509
	It("Should create a new X509 instance", func() {
		x = X509_new()
		Expect(x).NotTo(BeNil())
	})

	It("Should free the X509 instance", func() {
		X509_free(x)
	})

	Context("Reading PEM data from a memory BIO", func() {
		It("Should read with nil X509 and return new X509", func() {
			b := bio.BIO_new(bio.BIO_s_mem())
			cert := CERTS["google"]
			x = nil
			Expect(bio.BIO_write(b, cert, len(cert))).To(Equal(len(cert)))
			result := PEM_read_bio_X509(b, &x, nil, "")
			Expect(result).NotTo(BeNil())
			Expect(result).NotTo(BeEquivalentTo(0))
			X509_free(result)
			bio.BIO_free(b)
		})

		It("Should read with existing X509 and return new X509", func() {
			Skip("This test may contain a known OpenSSL bug")
			b := bio.BIO_new(bio.BIO_s_mem())
			cert := CERTS["google"]
			x = X509_new()
			Expect(bio.BIO_write(b, cert, len(cert))).To(Equal(len(cert)))
			// result := PEM_read_bio_X509(b, &x, nil, "")
			Expect(PEM_read_bio_X509(b, &x, nil, "")).To(BeEquivalentTo(0))