summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/lib/libtls/gotls/tls.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/regress/lib/libtls/gotls/tls.go b/regress/lib/libtls/gotls/tls.go
index 74c34b4064c..88d58ab33ba 100644
--- a/regress/lib/libtls/gotls/tls.go
+++ b/regress/lib/libtls/gotls/tls.go
@@ -26,7 +26,6 @@ var (
// TLSConfig provides configuration options for a TLS context.
type TLSConfig struct {
- caFile *C.char
tlsCfg *C.struct_tls_config
}
@@ -57,11 +56,9 @@ func NewConfig() (*TLSConfig, error) {
// SetCAFile sets the CA file to be used for connections.
func (c *TLSConfig) SetCAFile(filename string) {
- if c.caFile != nil {
- C.free(unsafe.Pointer(c.caFile))
- }
- c.caFile = C.CString(filename)
- C.tls_config_set_ca_file(c.tlsCfg, c.caFile)
+ caFile := C.CString(filename)
+ defer C.free(unsafe.Pointer(caFile))
+ C.tls_config_set_ca_file(c.tlsCfg, caFile)
}
// InsecureNoVerifyCert disables certificate verification for the connection.