Compare commits
1 commit
certificat
...
wip/webser
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f137fa11c |
3 changed files with 21 additions and 50 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
cli/cli
|
cli/cli
|
||||||
|
webservice/webservice
|
||||||
|
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
||||||
20
webservice/main.go
Normal file
20
webservice/main.go
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
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