Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Aug 6, 2024
1 parent a7ae113 commit 3f34d4c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions nodebuilder/p2p/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,36 @@ func tlsEnabled() (*tls.Config, bool, error) {
path := os.Getenv(tlsPath)
certPath := filepath.Join(path, cert)
keyPath := filepath.Join(path, key)

if path == "" {
log.Info("the CELESTIA_TLS_PATH was not set")
return nil, false, nil
}
exist := utils.Exists(certPath) && utils.Exists(keyPath)
if !exist {
return nil, false, nil
}

log.Info("creating a tls certificate")
var certificates []tls.Certificate
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, false, err
}
certificates = append(certificates, cert)
return &tls.Config{MinVersion: tls.VersionTLS12, Certificates: certificates}, true, nil
return &tls.Config{
MinVersion: tls.VersionTLS12,
Certificates: certificates,
}, true, nil
}

// wsTransport enables a support for the secure websocket connection
// using the passed tls config. The connection will be insecure in case
// config is empty.
func wsTransport(config *tls.Config) libp2p.Option {
if config == nil {
log.Info("using a default ws transport")
return libp2p.Transport(ws.New)
}
log.Info("using a wss transport with tlsConfig")
return libp2p.Transport(ws.New, ws.WithTLSConfig(config))
}

0 comments on commit 3f34d4c

Please sign in to comment.