Skip to content

Commit

Permalink
Convert lib/tlsca to use slog (#50297)
Browse files Browse the repository at this point in the history
  • Loading branch information
rosstimothy authored Dec 16, 2024
1 parent 1bf9cd5 commit 6018592
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions lib/tlsca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package tlsca

import (
"context"
"crypto"
"crypto/rand"
"crypto/rsa"
Expand All @@ -35,19 +36,17 @@ import (

"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/sirupsen/logrus"

"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
"github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/api/types/wrappers"
"github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/api/utils/keys"
logutils "github.com/gravitational/teleport/lib/utils/log"
)

var log = logrus.WithFields(logrus.Fields{
teleport.ComponentKey: teleport.ComponentAuthority,
})
var logger = logutils.NewPackageLogger(teleport.ComponentKey, teleport.ComponentAuthority)

// FromCertAndSigner returns a CertAuthority with the given raw certificate and signer.
func FromCertAndSigner(certPEM []byte, signer crypto.Signer) (*CertAuthority, error) {
Expand Down Expand Up @@ -1274,12 +1273,12 @@ func (ca *CertAuthority) GenerateCertificate(req CertificateRequest) ([]byte, er
return nil, trace.Wrap(err)
}

log.WithFields(logrus.Fields{
"not_after": req.NotAfter,
"dns_names": req.DNSNames,
"key_usage": req.KeyUsage,
"common_name": req.Subject.CommonName,
}).Debug("Generating TLS certificate")
logger.DebugContext(context.TODO(), "Generating TLS certificate",
"not_after", req.NotAfter,
"dns_names", req.DNSNames,
"key_usage", req.KeyUsage,
"common_name", req.Subject.CommonName,
)

template := &x509.Certificate{
SerialNumber: serialNumber,
Expand Down

0 comments on commit 6018592

Please sign in to comment.