mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-20 10:08:38 +02:00
ssh: add trailing newline to key strings if missing (#5716)
OpenSSH requires a trailing newline for private keys, which is easy to accidentally omit when configuring private keys as strings inline via copy/paste. This adds the missing newline if it is not present. Private keys read from files still require the trailing newline.
This commit is contained in:
parent
e5e9e4c14a
commit
651a7e061f
1 changed files with 9 additions and 1 deletions
|
@ -3,6 +3,7 @@ package envoyconfig
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
|
||||||
xds_core_v3 "github.com/cncf/xds/go/xds/core/v3"
|
xds_core_v3 "github.com/cncf/xds/go/xds/core/v3"
|
||||||
xds_matcher_v3 "github.com/cncf/xds/go/xds/type/matcher/v3"
|
xds_matcher_v3 "github.com/cncf/xds/go/xds/type/matcher/v3"
|
||||||
|
@ -52,6 +53,9 @@ func buildSSHListener(cfg *config.Config) (*envoy_config_listener_v3.Listener, e
|
||||||
}
|
}
|
||||||
if cfg.Options.SSHHostKeys != nil {
|
if cfg.Options.SSHHostKeys != nil {
|
||||||
for _, key := range *cfg.Options.SSHHostKeys {
|
for _, key := range *cfg.Options.SSHHostKeys {
|
||||||
|
if !strings.HasSuffix(key, "\n") {
|
||||||
|
key += "\n"
|
||||||
|
}
|
||||||
hostKeyDataSources = append(hostKeyDataSources, &envoy_config_core_v3.DataSource{
|
hostKeyDataSources = append(hostKeyDataSources, &envoy_config_core_v3.DataSource{
|
||||||
Specifier: &envoy_config_core_v3.DataSource_InlineString{
|
Specifier: &envoy_config_core_v3.DataSource_InlineString{
|
||||||
InlineString: key,
|
InlineString: key,
|
||||||
|
@ -67,9 +71,13 @@ func buildSSHListener(cfg *config.Config) (*envoy_config_listener_v3.Listener, e
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else if cfg.Options.SSHUserCAKey != "" {
|
} else if cfg.Options.SSHUserCAKey != "" {
|
||||||
|
key := cfg.Options.SSHUserCAKey
|
||||||
|
if !strings.HasSuffix(key, "\n") {
|
||||||
|
key += "\n"
|
||||||
|
}
|
||||||
userCaKeyDataSource = &envoy_config_core_v3.DataSource{
|
userCaKeyDataSource = &envoy_config_core_v3.DataSource{
|
||||||
Specifier: &envoy_config_core_v3.DataSource_InlineString{
|
Specifier: &envoy_config_core_v3.DataSource_InlineString{
|
||||||
InlineString: cfg.Options.SSHUserCAKey,
|
InlineString: key,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue