wip
This commit is contained in:
parent
00311952b5
commit
0c9f38fe38
50
testsuite/certificates.go
Normal file
50
testsuite/certificates.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user