-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
61 lines (48 loc) · 1.25 KB
/
main.go
File metadata and controls
61 lines (48 loc) · 1.25 KB
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"
import "log"
import "os"
import "strings"
/**
* Helper to panic on a returned error during setup
*/
func fatal(err error) {
if err != nil {
log.Panic(err)
}
}
/**
* Parse the certificates command flag and add to the handler
*/
func loadCertificates(flag string, handler *Verifier) (err error) {
// Use the default Amazon certificate if none are specified in command arguments
if len(flag) == 0 {
log.Printf("Using default Amazon AWS signing certificate")
_, err = handler.AddPEMCertificate(AmazonAWSCloudSigner)
return err
}
// Load certificates from specified files
for _, path := range strings.Split(flag, ",") {
if len(path) == 0 {
continue
}
_, err = handler.ReadPEMCertificate(path)
if err != nil {
return err
}
}
return nil
}
func main() {
var certs = flag.String("certificates", "", "Comma-separated list of paths to certificates used to verify signatures")
var socket = flag.String("socket", "./aws-verify.sock", "UNIX socket that verifier will listen on")
var mode = flag.Uint("mode", 0700, "File mode for listener socket")
flag.Parse()
handler := CreateVerifier()
fatal(
loadCertificates(*certs, handler),
)
fatal(
CreateServer(*socket, os.FileMode(*mode), handler).Listen(),
)
}