Esempio n. 1
0
func (self *Context) UseCertificateChainFile(file string) error {
	ret := int(C.SSL_CTX_use_certificate_chain_file(self.Ctx,
		C.CString(file)))
	if ret != 1 {
		return errors.New(sslerr.SSLErrorMessage())
	}
	return nil
}
Esempio n. 2
0
// UseCertificateChainFromFile loads a certificate chain from file into ctx.
// The certificates must be in PEM format and must be sorted starting with the
// subject's certificate (actual client or server certificate), followed by
// intermediate CA certificates if applicable, and ending at the highest level
// (root) CA. See
// https://www.openssl.org/docs/ssl/SSL_CTX_use_certificate.html
func (c *Ctx) UseCertificateChainFile(cert_file string) error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	var c_cert_file *C.char
	if cert_file != "" {
		c_cert_file = C.CString(cert_file)
		defer C.free(unsafe.Pointer(c_cert_file))
	}
	if int(C.SSL_CTX_use_certificate_chain_file(c.ctx, c_cert_file)) != 1 {
		return errorFromErrorQueue()
	}
	return nil
}