mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-26 15:22:15 +00:00
config: make possible to set absolute paths for TLS cert and key (#3765)
This commit is contained in:
parent
d4cf204087
commit
d9481e3648
@ -24,5 +24,6 @@ program](https://hackerone.com/tendermint).
|
|||||||
### FEATURES:
|
### FEATURES:
|
||||||
|
|
||||||
### IMPROVEMENTS:
|
### IMPROVEMENTS:
|
||||||
|
- [rpc] \#3700 Make possible to set absolute paths for TLS cert and key (@climber73)
|
||||||
|
|
||||||
### BUG FIXES:
|
### BUG FIXES:
|
||||||
|
@ -351,7 +351,8 @@ type RPCConfig struct {
|
|||||||
// See https://github.com/tendermint/tendermint/issues/3435
|
// See https://github.com/tendermint/tendermint/issues/3435
|
||||||
TimeoutBroadcastTxCommit time.Duration `mapstructure:"timeout_broadcast_tx_commit"`
|
TimeoutBroadcastTxCommit time.Duration `mapstructure:"timeout_broadcast_tx_commit"`
|
||||||
|
|
||||||
// The name of a file containing certificate that is used to create the HTTPS server.
|
// The path to a file containing certificate that is used to create the HTTPS server.
|
||||||
|
// Migth be either absolute path or path related to tendermint's config directory.
|
||||||
//
|
//
|
||||||
// If the certificate is signed by a certificate authority,
|
// If the certificate is signed by a certificate authority,
|
||||||
// the certFile should be the concatenation of the server's certificate, any intermediates,
|
// the certFile should be the concatenation of the server's certificate, any intermediates,
|
||||||
@ -360,7 +361,8 @@ type RPCConfig struct {
|
|||||||
// NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
// NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
||||||
TLSCertFile string `mapstructure:"tls_cert_file"`
|
TLSCertFile string `mapstructure:"tls_cert_file"`
|
||||||
|
|
||||||
// The name of a file containing matching private key that is used to create the HTTPS server.
|
// The path to a file containing matching private key that is used to create the HTTPS server.
|
||||||
|
// Migth be either absolute path or path related to tendermint's config directory.
|
||||||
//
|
//
|
||||||
// NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
// NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
||||||
TLSKeyFile string `mapstructure:"tls_key_file"`
|
TLSKeyFile string `mapstructure:"tls_key_file"`
|
||||||
@ -424,11 +426,19 @@ func (cfg *RPCConfig) IsCorsEnabled() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cfg RPCConfig) KeyFile() string {
|
func (cfg RPCConfig) KeyFile() string {
|
||||||
return rootify(filepath.Join(defaultConfigDir, cfg.TLSKeyFile), cfg.RootDir)
|
path := cfg.TLSKeyFile
|
||||||
|
if filepath.IsAbs(path) {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
return rootify(filepath.Join(defaultConfigDir, path), cfg.RootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg RPCConfig) CertFile() string {
|
func (cfg RPCConfig) CertFile() string {
|
||||||
return rootify(filepath.Join(defaultConfigDir, cfg.TLSCertFile), cfg.RootDir)
|
path := cfg.TLSCertFile
|
||||||
|
if filepath.IsAbs(path) {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
return rootify(filepath.Join(defaultConfigDir, path), cfg.RootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg RPCConfig) IsTLSEnabled() bool {
|
func (cfg RPCConfig) IsTLSEnabled() bool {
|
||||||
|
@ -36,3 +36,19 @@ func TestConfigValidateBasic(t *testing.T) {
|
|||||||
cfg.Consensus.TimeoutPropose = -10 * time.Second
|
cfg.Consensus.TimeoutPropose = -10 * time.Second
|
||||||
assert.Error(t, cfg.ValidateBasic())
|
assert.Error(t, cfg.ValidateBasic())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTLSConfiguration(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
cfg := DefaultConfig()
|
||||||
|
cfg.SetRoot("/home/user")
|
||||||
|
|
||||||
|
cfg.RPC.TLSCertFile = "file.crt"
|
||||||
|
assert.Equal("/home/user/config/file.crt", cfg.RPC.CertFile())
|
||||||
|
cfg.RPC.TLSKeyFile = "file.key"
|
||||||
|
assert.Equal("/home/user/config/file.key", cfg.RPC.KeyFile())
|
||||||
|
|
||||||
|
cfg.RPC.TLSCertFile = "/abs/path/to/file.crt"
|
||||||
|
assert.Equal("/abs/path/to/file.crt", cfg.RPC.CertFile())
|
||||||
|
cfg.RPC.TLSKeyFile = "/abs/path/to/file.key"
|
||||||
|
assert.Equal("/abs/path/to/file.key", cfg.RPC.KeyFile())
|
||||||
|
}
|
||||||
|
@ -192,14 +192,16 @@ max_subscriptions_per_client = {{ .RPC.MaxSubscriptionsPerClient }}
|
|||||||
# See https://github.com/tendermint/tendermint/issues/3435
|
# See https://github.com/tendermint/tendermint/issues/3435
|
||||||
timeout_broadcast_tx_commit = "{{ .RPC.TimeoutBroadcastTxCommit }}"
|
timeout_broadcast_tx_commit = "{{ .RPC.TimeoutBroadcastTxCommit }}"
|
||||||
|
|
||||||
# The name of a file containing certificate that is used to create the HTTPS server.
|
# The path to a file containing certificate that is used to create the HTTPS server.
|
||||||
|
# Migth be either absolute path or path related to tendermint's config directory.
|
||||||
# If the certificate is signed by a certificate authority,
|
# If the certificate is signed by a certificate authority,
|
||||||
# the certFile should be the concatenation of the server's certificate, any intermediates,
|
# the certFile should be the concatenation of the server's certificate, any intermediates,
|
||||||
# and the CA's certificate.
|
# and the CA's certificate.
|
||||||
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
||||||
tls_cert_file = "{{ .RPC.TLSCertFile }}"
|
tls_cert_file = "{{ .RPC.TLSCertFile }}"
|
||||||
|
|
||||||
# The name of a file containing matching private key that is used to create the HTTPS server.
|
# The path to a file containing matching private key that is used to create the HTTPS server.
|
||||||
|
# Migth be either absolute path or path related to tendermint's config directory.
|
||||||
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
||||||
tls_key_file = "{{ .RPC.TLSKeyFile }}"
|
tls_key_file = "{{ .RPC.TLSKeyFile }}"
|
||||||
|
|
||||||
|
@ -138,14 +138,16 @@ max_subscriptions_per_client = 5
|
|||||||
# See https://github.com/tendermint/tendermint/issues/3435
|
# See https://github.com/tendermint/tendermint/issues/3435
|
||||||
timeout_broadcast_tx_commit = "10s"
|
timeout_broadcast_tx_commit = "10s"
|
||||||
|
|
||||||
# The name of a file containing certificate that is used to create the HTTPS server.
|
# The path to a file containing certificate that is used to create the HTTPS server.
|
||||||
|
# Migth be either absolute path or path related to tendermint's config directory.
|
||||||
# If the certificate is signed by a certificate authority,
|
# If the certificate is signed by a certificate authority,
|
||||||
# the certFile should be the concatenation of the server's certificate, any intermediates,
|
# the certFile should be the concatenation of the server's certificate, any intermediates,
|
||||||
# and the CA's certificate.
|
# and the CA's certificate.
|
||||||
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
||||||
tls_cert_file = ""
|
tls_cert_file = ""
|
||||||
|
|
||||||
# The name of a file containing matching private key that is used to create the HTTPS server.
|
# The path to a file containing matching private key that is used to create the HTTPS server.
|
||||||
|
# Migth be either absolute path or path related to tendermint's config directory.
|
||||||
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
# NOTE: both tls_cert_file and tls_key_file must be present for Tendermint to create HTTPS server. Otherwise, HTTP server is run.
|
||||||
tls_key_file = ""
|
tls_key_file = ""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user