Skip to content

Commit fcaa8ab

Browse files
authored
feat: enable specifying root ca for oidc (#6712)
When configuring an external OIDC provider which uses a private PKI for its certificates it was not possible to properly verify the certificate being served. Also, when using ArgoCD in insecure mode, e.g. when running behind istio for providing mTLS, this resulted in errors. Signed-off-by: Clive Jevons <clive@jevons-it.net>
1 parent e32c070 commit fcaa8ab

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

docs/operator-manual/user-management/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,21 @@ You are not required to specify a logoutRedirectURL as this is automatically gen
373373
!!! note
374374
The post logout redirect URI may need to be whitelisted against your OIDC provider's client settings for ArgoCD.
375375

376+
### Configuring a custom root CA certificate for communicating with the OIDC provider
377+
378+
If your OIDC provider is setup with a certificate which is not signed by one of the well known certificate authorities
379+
you can provide a custom certificate which will be used in verifying the OIDC provider's TLS certificate when
380+
communicating with it.
381+
Add a `rootCA` to your `oidc.config` which contains the PEM encoded root certificate:
382+
383+
```yaml
384+
oidc.config: |
385+
...
386+
rootCA: |
387+
-----BEGIN CERTIFICATE-----
388+
... encoded certificate data here ...
389+
-----END CERTIFICATE-----
390+
```
376391

377392

378393
## SSO Further Reading

util/oidc/oidc.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ func NewClientApp(settings *settings.ArgoCDSettings, cache OIDCStateStorage, dex
107107
if err != nil {
108108
return nil, fmt.Errorf("parse redirect-uri: %v", err)
109109
}
110-
tlsConfig := settings.TLSConfig()
111-
if tlsConfig != nil {
112-
tlsConfig.InsecureSkipVerify = true
113-
}
110+
tlsConfig := settings.OIDCTLSConfig()
114111
a.client = &http.Client{
115112
Transport: &http.Transport{
116113
TLSClientConfig: tlsConfig,

util/settings/settings.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type OIDCConfig struct {
121121
RequestedScopes []string `json:"requestedScopes,omitempty"`
122122
RequestedIDTokenClaims map[string]*oidc.Claim `json:"requestedIDTokenClaims,omitempty"`
123123
LogoutURL string `json:"logoutURL,omitempty"`
124+
RootCA string `json:"rootCA,omitempty"`
124125
}
125126

126127
// DEPRECATED. Helm repository credentials are now managed using RepoCredentials
@@ -1530,6 +1531,27 @@ func (a *ArgoCDSettings) OAuth2ClientSecret() string {
15301531
return ""
15311532
}
15321533

1534+
func (a *ArgoCDSettings) OIDCTLSConfig() *tls.Config {
1535+
if oidcConfig := a.OIDCConfig(); oidcConfig != nil {
1536+
if oidcConfig.RootCA != "" {
1537+
certPool := x509.NewCertPool()
1538+
ok := certPool.AppendCertsFromPEM([]byte(oidcConfig.RootCA))
1539+
if !ok {
1540+
log.Warn("invalid oidc root ca cert - returning default tls.Config instead")
1541+
return &tls.Config{}
1542+
}
1543+
return &tls.Config{
1544+
RootCAs: certPool,
1545+
}
1546+
}
1547+
}
1548+
tlsConfig := a.TLSConfig()
1549+
if tlsConfig != nil {
1550+
tlsConfig.InsecureSkipVerify = true
1551+
}
1552+
return tlsConfig
1553+
}
1554+
15331555
func appendURLPath(inputURL string, inputPath string) (string, error) {
15341556
u, err := url.Parse(inputURL)
15351557
if err != nil {

0 commit comments

Comments
 (0)