Skip to content

Commit

Permalink
Update ioutil.WriteFile to os.WriteFile
Browse files Browse the repository at this point in the history
  • Loading branch information
mtnmunuklu committed Feb 15, 2024
1 parent 4ba673b commit 8ca930a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions scripts/certs/generate_certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"io/ioutil"
"math/big"
"os"
"time"
Expand Down Expand Up @@ -189,23 +188,23 @@ func savePrivateKey(filename string, key *ecdsa.PrivateKey) {
}

pemBlock := &pem.Block{Type: "EC PRIVATE KEY", Bytes: keyBytes}
err = ioutil.WriteFile(filename, pem.EncodeToMemory(pemBlock), 0644)
err = os.WriteFile(filename, pem.EncodeToMemory(pemBlock), 0644)
if err != nil {
fmt.Printf("Error writing private key to file: %v\n", err)
}
}

func saveCertificateRequest(filename string, req []byte) {
pemBlock := &pem.Block{Type: "CERTIFICATE REQUEST", Bytes: req}
err := ioutil.WriteFile(filename, pem.EncodeToMemory(pemBlock), 0644)
err := os.WriteFile(filename, pem.EncodeToMemory(pemBlock), 0644)
if err != nil {
fmt.Printf("Error writing certificate request to file: %v\n", err)
}
}

func saveCertificate(filename string, cert []byte) {
pemBlock := &pem.Block{Type: "CERTIFICATE", Bytes: cert}
err := ioutil.WriteFile(filename, pem.EncodeToMemory(pemBlock), 0644)
err := os.WriteFile(filename, pem.EncodeToMemory(pemBlock), 0644)
if err != nil {
fmt.Printf("Error writing certificate to file: %v\n", err)
}
Expand Down

0 comments on commit 8ca930a

Please sign in to comment.