Use openssl bindings instead of builtins crypto/tls for protocol testsuite

This commit is contained in:
nemunaire 2015-07-29 21:01:09 +02:00
parent 5bbb306006
commit f322f22d2a
1 changed files with 25 additions and 20 deletions

View File

@ -1,8 +1,8 @@
package testsuite package testsuite
import ( import (
"crypto/tls"
"github.com/nemunaire/eyespot" "github.com/nemunaire/eyespot"
"github.com/spacemonkeygo/openssl"
) )
type Protocols struct { type Protocols struct {
@ -15,11 +15,12 @@ func (Protocols) GetTestDescription() string {
func (test Protocols) Run(protocol string, host string) (map[string]eyespot.Result, error) { func (test Protocols) Run(protocol string, host string) (map[string]eyespot.Result, error) {
var results = map[string]eyespot.Result{} var results = map[string]eyespot.Result{}
for _, v := range []uint16{ for _, v := range []openssl.SSLVersion{
tls.VersionSSL30, //0x01, // openssl.SSLv2
tls.VersionTLS10, openssl.SSLv3,
tls.VersionTLS11, openssl.TLSv1,
tls.VersionTLS12, openssl.TLSv1_1,
openssl.TLSv1_2,
} { } {
if r, err := protocol_test(protocol, host, v); err != nil { if r, err := protocol_test(protocol, host, v); err != nil {
return results, err return results, err
@ -27,14 +28,16 @@ func (test Protocols) Run(protocol string, host string) (map[string]eyespot.Resu
var cstr string var cstr string
switch v { switch v {
case tls.VersionSSL30: case 0x01:
cstr = "VersionSSL30" cstr = "SSLv2"
case tls.VersionTLS10: case openssl.SSLv3:
cstr = "VersionTLS10" cstr = "SSLv3"
case tls.VersionTLS11: case openssl.TLSv1:
cstr = "VersionTLS11" cstr = "TLSv1"
case tls.VersionTLS12: case openssl.TLSv1_1:
cstr = "VersionTLS12" cstr = "TLSv1.1"
case openssl.TLSv1_2:
cstr = "TLSv1.2"
default: default:
cstr = "" cstr = ""
} }
@ -46,12 +49,14 @@ func (test Protocols) Run(protocol string, host string) (map[string]eyespot.Resu
return results, nil return results, nil
} }
func protocol_test(protocol string, host string, version uint16) (bool, error) { func protocol_test(protocol string, host string, version openssl.SSLVersion) (bool, error) {
conn, err := tls.Dial(protocol, host, &tls.Config{ ctx, err := openssl.NewCtxWithVersion(version)
MinVersion: version,
MaxVersion: version, if err != nil {
InsecureSkipVerify: true, return false, err
}) }
conn, err := openssl.Dial(protocol, host, ctx, openssl.InsecureSkipHostVerification)
if err != nil { if err != nil {
return false, nil return false, nil
} }