Compare commits
1 commit
wip/webser
...
certificat
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c9f38fe38 |
3 changed files with 50 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
||||||
cli/cli
|
cli/cli
|
||||||
webservice/webservice
|
|
||||||
|
|
|
||||||
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
|
||||||
|
}
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var port = flag.Int("port", 8080, "Listening port")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
log.Println("Registering handlers...")
|
|
||||||
mux := http.NewServeMux()
|
|
||||||
http.HandleFunc("/", mux.ServeHTTP)
|
|
||||||
|
|
||||||
log.Println(fmt.Sprintf("Ready, listening on port %d", *port))
|
|
||||||
http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue