summaryrefslogtreecommitdiff
path: root/src/regress/lib/libtls/gotls/tls.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress/lib/libtls/gotls/tls.go')
-rw-r--r--src/regress/lib/libtls/gotls/tls.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/regress/lib/libtls/gotls/tls.go b/src/regress/lib/libtls/gotls/tls.go
index 4ce92eaef8..c6aab7789f 100644
--- a/src/regress/lib/libtls/gotls/tls.go
+++ b/src/regress/lib/libtls/gotls/tls.go
@@ -53,11 +53,22 @@ func NewConfig() (*TLSConfig, error) {
53 }, nil 53 }, nil
54} 54}
55 55
56// Error returns the error message from the TLS configuration.
57func (c *TLSConfig) Error() error {
58 if msg := C.tls_config_error(c.tlsCfg); msg != nil {
59 return errors.New(C.GoString(msg))
60 }
61 return errors.New("unknown error")
62}
63
56// SetCAFile sets the CA file to be used for connections. 64// SetCAFile sets the CA file to be used for connections.
57func (c *TLSConfig) SetCAFile(filename string) { 65func (c *TLSConfig) SetCAFile(filename string) error {
58 caFile := C.CString(filename) 66 caFile := C.CString(filename)
59 defer C.free(unsafe.Pointer(caFile)) 67 defer C.free(unsafe.Pointer(caFile))
60 C.tls_config_set_ca_file(c.tlsCfg, caFile) 68 if C.tls_config_set_ca_file(c.tlsCfg, caFile) != 0 {
69 return c.Error()
70 }
71 return nil
61} 72}
62 73
63// InsecureNoVerifyCert disables certificate verification for the connection. 74// InsecureNoVerifyCert disables certificate verification for the connection.