Skip to content

Commit

Permalink
use url.JoinPath to correctly escape and join x5u and chainName
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhodges committed Sep 4, 2024
1 parent 0fdb335 commit b91d6ce
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions signer/contentsignaturepki/x509.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"encoding/pem"
"fmt"
"math/big"
"path"
"net/url"
"time"

"github.com/mozilla-services/autograph/database"
Expand Down Expand Up @@ -42,23 +42,25 @@ func (s *ContentSigner) findAndSetEE(conf signer.Configuration) (err error) {

// makeAndUploadChain makes a certificate using the end-entity public key,
// uploads the chain to its destination and creates an X5U download URL
func (s *ContentSigner) makeAndUploadChain() (err error) {
var fullChain, chainName string
fullChain, chainName, err = s.makeChain()
func (s *ContentSigner) makeAndUploadChain() error {
fullChain, chainName, err := s.makeChain()
if err != nil {
return fmt.Errorf("failed to make chain: %w", err)
}
err = s.upload(fullChain, chainName)
if err != nil {
return fmt.Errorf("failed to upload chain: %w", err)
}
newX5U := path.Join(s.X5U, chainName)
newX5U, err := url.JoinPath(s.X5U, chainName)
if err != nil {
return fmt.Errorf("failed to join x5u with chain name: %w", err)
}
_, _, err = GetX5U(buildHTTPClient(), newX5U)
if err != nil {
return fmt.Errorf("failed to download new chain: %w", err)
}
s.X5U = newX5U
return
return nil
}

// makeChain issues an end-entity certificate using the ca private key and the first
Expand Down

0 comments on commit b91d6ce

Please sign in to comment.