Skip to content

Commit

Permalink
fix golintci-lint issues
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry S <dsavints@gmail.com>
  • Loading branch information
dmitris committed Jul 18, 2023
1 parent 876c313 commit 3460165
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions test/gencert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageCodeSigning /*, x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth */},
KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
EmailAddresses: []string{"iamca@nosuchprovider.com"},
EmailAddresses: []string{"ca@example.com"},
}

// create our private and public key
Expand All @@ -64,21 +64,30 @@ func main() {
}

// pem encode
caCertFile, err := os.OpenFile("cacert.pem", os.O_RDWR|os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
pem.Encode(caCertFile, &pem.Block{
caCertFile, err := os.OpenFile("cacert.pem", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
log.Fatalf("unable to write to cacert.pem: %v", err)
}
err = pem.Encode(caCertFile, &pem.Block{
Type: "CERTIFICATE",
Bytes: caBytes,
})
if err != nil {
log.Fatalf("unable to write to cacert.pem: %v", err)
}

caPrivKeyFile, err := os.OpenFile("ca-key.pem", os.O_RDWR|os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0400)
caPrivKeyFile, err := os.OpenFile("ca-key.pem", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0400)
if err != nil {
log.Fatal(err)
}
defer caPrivKeyFile.Close()
pem.Encode(caPrivKeyFile, &pem.Block{
err = pem.Encode(caPrivKeyFile, &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(caPrivKey),
})
if err != nil {
log.Fatalf("unable to create to ca-key.pem: %v", err) //nolint:gocritic
}

// set up our server certificate
cert := &x509.Certificate{
Expand Down Expand Up @@ -137,4 +146,3 @@ func main() {
log.Fatalf("failed to encode private key: %v", err)
}
}

0 comments on commit 3460165

Please sign in to comment.