5
5
"encoding/json"
6
6
"fmt"
7
7
"io"
8
- "io/ioutil"
9
8
"net/http"
10
9
"os"
11
10
@@ -65,7 +64,7 @@ func initAPICall(token, hostname, zoneID, csr string) ([]byte, error) {
65
64
}
66
65
defer resp .Body .Close ()
67
66
68
- bodyBytes , err := ioutil .ReadAll (resp .Body )
67
+ bodyBytes , err := io .ReadAll (resp .Body )
69
68
if err != nil {
70
69
return nil , fmt .Errorf ("certificate API returned an invalid response body for HTTP %d" , resp .StatusCode )
71
70
}
@@ -120,12 +119,12 @@ func initializeServerCertAndKey() {
120
119
log .Fatal ("failed to generate csr and key: " , err )
121
120
}
122
121
123
- if err := ioutil .WriteFile (config .KeyFile , key , 0600 ); err != nil {
122
+ if err := os .WriteFile (config .KeyFile , key , 0600 ); err != nil {
124
123
log .Fatal ("failed to write to key file: " , err )
125
124
}
126
125
log .Infof ("key is generated and saved to %s" , config .KeyFile )
127
126
128
- if err := ioutil .WriteFile (config .CSRFile , csr , 0600 ); err != nil {
127
+ if err := os .WriteFile (config .CSRFile , csr , 0600 ); err != nil {
129
128
log .Fatal ("failed to write to csr file:" , err )
130
129
}
131
130
log .Infof ("csr is generated and saved to %s" , config .CSRFile )
@@ -141,12 +140,11 @@ func initializeServerCertAndKey() {
141
140
log .Fatal ("couldn't remove old certificate file: " , err )
142
141
}
143
142
144
- if err := ioutil .WriteFile (config .CertFile , cert , 0644 ); err != nil {
143
+ if err := os .WriteFile (config .CertFile , cert , 0644 ); err != nil {
145
144
log .Fatal ("couldn't write to certificate file: " , err )
146
145
}
147
146
log .Infof ("certificate saved to %s" , config .CertFile )
148
147
149
- return
150
148
}
151
149
152
150
// generateCSR generates a private key and a CSR for the given host. The
@@ -155,7 +153,7 @@ func generateCSR(host string) ([]byte, []byte, error) {
155
153
csr , key , err := csr .ParseRequest (& csr.CertificateRequest {
156
154
CN : "Keyless Server Authentication Certificate" ,
157
155
Hosts : []string {host },
158
- KeyRequest : & csr.BasicKeyRequest {
156
+ KeyRequest : & csr.KeyRequest {
159
157
A : "ecdsa" ,
160
158
S : 384 ,
161
159
},
@@ -173,12 +171,12 @@ func manualActivation() {
173
171
log .Fatal ("failed to generate csr and key: " , err )
174
172
}
175
173
176
- if err := ioutil .WriteFile (config .KeyFile , key , 0600 ); err != nil {
174
+ if err := os .WriteFile (config .KeyFile , key , 0600 ); err != nil {
177
175
log .Fatal ("failed to write to key file:" , err )
178
176
}
179
177
log .Infof ("key is generated and saved to %s" , config .KeyFile )
180
178
181
- if err := ioutil .WriteFile (config .CSRFile , csr , 0600 ); err != nil {
179
+ if err := os .WriteFile (config .CSRFile , csr , 0600 ); err != nil {
182
180
log .Fatal ("failed to write to csr file:" , err )
183
181
}
184
182
log .Infof ("csr is generated and saved to %s" , config .CSRFile )
0 commit comments