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

View File

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