예제 #1
0
파일: context.go 프로젝트: postfix/go-ssl
func (self *Context) LoadVerifyLocations(cafile, capath *string) int {
	if cafile != nil && capath != nil {
		return int(C.SSL_CTX_load_verify_locations(self.Ctx,
			C.CString(*cafile), C.CString(*capath)))
	}
	if cafile == nil {
		return int(C.SSL_CTX_load_verify_locations(self.Ctx,
			nil, C.CString(*capath)))
	}
	if capath == nil {
		return int(C.SSL_CTX_load_verify_locations(self.Ctx,
			C.CString(*cafile), nil))
	}
	return -1
}
예제 #2
0
// LoadVerifyLocations tells the context to trust all certificate authorities
// provided in either the ca_file or the ca_path.
// See http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html for
// more.
func (c *Ctx) LoadVerifyLocations(ca_file string, ca_path string) error {
	runtime.LockOSThread()
	defer runtime.UnlockOSThread()
	var c_ca_file, c_ca_path *C.char
	if ca_file != "" {
		c_ca_file = C.CString(ca_file)
		defer C.free(unsafe.Pointer(c_ca_file))
	}
	if ca_path != "" {
		c_ca_path = C.CString(ca_path)
		defer C.free(unsafe.Pointer(c_ca_path))
	}
	if C.SSL_CTX_load_verify_locations(c.ctx, c_ca_file, c_ca_path) != 1 {
		return errorFromErrorQueue()
	}
	return nil
}