Skip to content

Commit

Permalink
Merge pull request #61 from iarspider/patch-1
Browse files Browse the repository at this point in the history
Fix X509_USER_PROXY handling
  • Loading branch information
vkuznet authored Jan 9, 2024
2 parents 4f7f902 + 3025d53 commit fd40de8
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions utils/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,24 @@ func tlsCerts() ([]tls.Certificate, error) {
uckey := os.Getenv("X509_USER_KEY")
ucert := os.Getenv("X509_USER_CERT")

// check if /tmp/x509up_u$UID exists, if so setup X509_USER_PROXY env
u, err := user.Current()
if err == nil {
fname := fmt.Sprintf("/tmp/x509up_u%s", u.Uid)
if _, err := os.Stat(fname); err == nil {
uproxy = fname
// check for proxy in $X509_USER_PROXY
if uproxy != "" {
if _, err := os.Stat(uproxy); err != nil {
uproxy = ""
}
}

if uproxy == "" {
// fall back to /tmp/x509up_u$UID
u, err := user.Current()
if err == nil {
fname := fmt.Sprintf("/tmp/x509up_u%s", u.Uid)
if _, err := os.Stat(fname); err == nil {
uproxy = fname
}
}
}

if WEBSERVER == 1 {
log.Printf("tls certs, X509_USER_PROXY=%v, X509_USER_KEY=%v, X509_USER_CERT=%v\n", uproxy, uckey, ucert)
}
Expand Down

0 comments on commit fd40de8

Please sign in to comment.