/
openssl.go
50 lines (41 loc) · 1.03 KB
/
openssl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package impltests
import (
"fmt"
test_executor "github.com/Netflix/bettertls/test-suites/test-executor"
"net"
)
type OpensslRunner struct {
version string
}
func (o *OpensslRunner) Name() string {
return "openssl"
}
func (o *OpensslRunner) Initialize() error {
var err error
o.version, err = execAndCapture("openssl", "version")
if err != nil {
return err
}
return nil
}
func (o *OpensslRunner) Close() error {
return nil
}
func (o *OpensslRunner) GetVersion() string {
return o.version
}
func (o *OpensslRunner) RunTests(ctx *test_executor.ExecutionContext) (map[string]*test_executor.SuiteTestResults, error) {
return testExec(ctx, func(caPath string, hostname string, tlsPort uint) []string {
args := []string{"openssl", "s_client",
"-CAfile", caPath,
"-connect", fmt.Sprintf("%s:%d", hostname, tlsPort),
"-verify_return_error"}
ipAddr := net.ParseIP(hostname)
if ipAddr == nil {
args = append(args, "-verify_hostname", hostname)
} else {
args = append(args, "-verify_ip", hostname)
}
return args
})
}