Skip to content
This repository has been archived by the owner on Apr 11, 2021. It is now read-only.

Commit

Permalink
add flag option for TLS/SSL check
Browse files Browse the repository at this point in the history
  • Loading branch information
yanc0 committed May 7, 2017
1 parent 205644a commit 27f536d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions beeping.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var geodatfile *string
var instance *string
var listen *string
var port *string
var tlsmode *bool

type Beeping struct {
Version string `json:"version"`
Expand Down Expand Up @@ -85,6 +86,7 @@ func main() {
instance = flag.String("instance", "", "beeping instance name (default hostname)")
listen = flag.String("listen", "127.0.0.1", "The host to bind the server to")
port = flag.String("port", "8080", "The port to bind the server to")
tlsmode = flag.Bool("tlsmode", false, "Activate SSL/TLS versions and Cipher support checks")
flag.Parse()

gin.SetMode("release")
Expand Down Expand Up @@ -196,8 +198,10 @@ func CheckHTTP(check *Check) (*Response, error) {

if res.TLS != nil {
cTLS := &sslcheck.CheckSSL{}
cTLS.CheckCiphers(conn)
cTLS.CheckVersions(conn)
if *tlsmode {
cTLS.CheckCiphers(conn)
cTLS.CheckVersions(conn)
}
cTLS.CertExpiryDate = res.TLS.PeerCertificates[0].NotAfter
cTLS.CertExpiryDaysLeft = int64(cTLS.CertExpiryDate.Sub(time.Now()).Hours() / 24)
cTLS.CertSignature = res.TLS.PeerCertificates[0].SignatureAlgorithm.String()
Expand Down
5 changes: 2 additions & 3 deletions sslcheck/tlscheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ package sslcheck

import (
"crypto/tls"
"log"
"net"
"time"
)

type CheckSSL struct {
Ciphers []string `json:"ciphers"`
ProtocolVersion []string `json:"protocol_versions"`
Ciphers []string `json:"ciphers,omitempty"`
ProtocolVersion []string `json:"protocol_versions,omitempty"`
CertExpiryDate time.Time `json:"cert_expiry_date"`
CertExpiryDaysLeft int64 `json:"cert_expiry_days_left"`
CertSignature string `json:"cert_signature"`
Expand Down

0 comments on commit 27f536d

Please sign in to comment.