-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (41 loc) · 1.04 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"crypto/x509"
"log"
"os"
"github.com/pborman/getopt"
)
type TlsCat struct {
crt *x509.Certificate
key string
}
func main() {
help := getopt.BoolLong("help", 'h', "display this help")
crt := getopt.StringLong("crt", 'c', "", "crt file")
server := getopt.StringLong("server", 's', "", "remote server")
server_name := getopt.StringLong("server-name", 'n', "", "optional server name")
port := getopt.StringLong("port", 'p', "443", "optional port, default:443")
key_file := getopt.StringLong("key-file", 'k', "", "key file")
key_check := getopt.BoolLong("key-check", 'C', "private key validation")
verbose := getopt.BoolLong("verbose", 'v', "verbose output")
getopt.Parse()
if *help {
getopt.Usage()
os.Exit(0)
}
var c TlsCat
var err error
stat, _ := os.Stdin.Stat()
c.crt, err = readCertificate(*crt, *server, *port, *server_name, stat)
if err != nil {
log.Fatal(err)
}
if *key_check {
err = c.keyCompare(*key_file, *verbose)
if err != nil {
log.Fatal(err)
}
os.Exit(0)
}
c.printCertificate()
}