This commit is contained in:
nemunaire 2015-09-02 10:15:50 +02:00
parent 00311952b5
commit 0c9f38fe38
1 changed files with 50 additions and 0 deletions

50
testsuite/certificates.go Normal file
View File

@ -0,0 +1,50 @@
package testsuite
import (
"fmt"
"github.com/nemunaire/eyespot"
"github.com/spacemonkeygo/openssl"
)
type Certificates struct {}
func (Certificates) GetTestDescription() string {
return "Test the certificate of the remote host."
}
func (test Certificates) Run(protocol string, host string) (map[string]eyespot.Result, error) {
var results = map[string]eyespot.Result{}
ctx, err := openssl.NewCtx()
if err != nil {
return results, err
}
conn, err := openssl.Dial(protocol, host, ctx, openssl.InsecureSkipHostVerification)
if err != nil {
return results, err
}
defer conn.Close();
// if err := conn.Handshake(); err != nil {
// return err
// }
cert, err := conn.PeerCertificate()
if err != nil {
return results, err
}
nm, err := cert.GetIssuerName()
if err != nil {
return results, err
}
if str, ok := nm.GetEntry(13); ok != false {
fmt.Printf(str)
}
return results, nil
}