File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -57,20 +57,34 @@ func GenerateCert(dst string) error {
57
57
if err != nil {
58
58
return fmt .Errorf ("Could not open %s for writing: %s" , dst , err )
59
59
}
60
- pem .Encode (certOut , & pem.Block {Type : "CERTIFICATE" , Bytes : derBytes })
61
- certOut .Close ()
60
+ err = pem .Encode (certOut , & pem.Block {Type : "CERTIFICATE" , Bytes : derBytes })
61
+ if err != nil {
62
+ return err
63
+ }
64
+
65
+ err = certOut .Close ()
66
+ if err != nil {
67
+ return err
68
+ }
62
69
63
70
keyOut , err := os .OpenFile (dst , os .O_WRONLY | os .O_APPEND , 0600 )
64
71
if err != nil {
65
72
return fmt .Errorf ("Could not open %s for writing: %s" , dst , err )
66
73
}
67
- pem .Encode (
74
+ err = pem .Encode (
68
75
keyOut ,
69
76
& pem.Block {
70
77
Type : "RSA PRIVATE KEY" ,
71
78
Bytes : x509 .MarshalPKCS1PrivateKey (priv ),
72
79
},
73
80
)
74
- keyOut .Close ()
81
+ if err != nil {
82
+ return err
83
+ }
84
+
85
+ err = keyOut .Close ()
86
+ if err != nil {
87
+ return err
88
+ }
75
89
return nil
76
90
}
You can’t perform that action at this time.
0 commit comments