-
Notifications
You must be signed in to change notification settings - Fork 0
/
vsym.go
68 lines (59 loc) · 1.22 KB
/
vsym.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
62
63
64
65
66
67
68
package vsym
import (
"fmt"
"os"
"strings"
"time"
"github.com/genkiroid/cert"
)
var Issuers = []string{
"Symantec",
"GeoTrust",
"thawte",
"RapidSSL",
"VeriSign",
"Equifax",
}
type VSym struct {
certs cert.Certs
}
func NewVSym() (*VSym, error) {
certs, err := cert.NewCerts(os.Args[1:])
if err != nil {
return nil, err
}
return &VSym{certs}, nil
}
func symantecIssued(cert *cert.Cert) bool {
for _, c := range cert.CertChain() {
for _, issuer := range Issuers {
if strings.Contains(strings.ToLower(c.Issuer.CommonName), strings.ToLower(issuer)) {
issuedDate := c.NotBefore.In(time.Local)
baseDate := time.Date(2017, time.December, 1, 0, 0, 0, 0, time.Local)
if issuedDate.Before(baseDate) {
return true
}
}
}
}
return false
}
func chromeVer(cert *cert.Cert) string {
issuedDate := cert.Detail().NotBefore.In(time.Local)
baseDate := time.Date(2016, time.June, 1, 0, 0, 0, 0, time.Local)
if issuedDate.Before(baseDate) {
return "v66"
}
return "v70"
}
func (v *VSym) Verify() {
for _, cert := range v.certs {
if symantecIssued(cert) {
fmt.Printf(
"The SSL certificate used on https://%s will be distrusted in Chrome %s.\n",
cert.DomainName,
chromeVer(cert),
)
}
}
}