-
Notifications
You must be signed in to change notification settings - Fork 0
/
tlschk.go
61 lines (48 loc) · 997 Bytes
/
tlschk.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
52
53
54
55
56
57
58
59
60
61
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/chzyer/readline"
"github.com/mattn/go-isatty"
)
func main() {
var err error
defer func() {
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
}
}()
cfg := Settings{
Now: time.Now(),
IsTTY: isatty.IsTerminal(os.Stdout.Fd()),
}
flag.BoolVar(&cfg.Details, FLAG_DETAILS, false, "full cert details in JSON format")
flag.BoolVar(&cfg.FullChain, FLAG_FULLCHAIN, false, "report all certs in chain")
flag.BoolVar(&cfg.Verify, FLAG_VERIFY, false, "verify all certs in chain")
flag.Parse()
sDomains := flag.Args()
if len(sDomains) > 0 {
// queries from args
for _, domain := range sDomains {
cfg.ProcessLine(domain)
}
} else {
// TODO: save & restore repl entries
// queries from REPL
rl, err := readline.New("> ")
if err != nil {
return
}
defer rl.Close()
for {
domain, e2 := rl.Readline()
if e2 != nil {
err = e2
return
}
cfg.ProcessLine(domain)
}
}
}