Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions internal/rotate_est.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"io"
"log/slog"
"net/http"
"strings"

"github.com/foundriesio/fioconfig/sotatoml"
"go.mozilla.org/pkcs7"
Expand Down Expand Up @@ -82,13 +83,17 @@ func (s estStep) Execute(handler *certRotationContext) error {
if err != nil {
return fmt.Errorf("Unable to read certificate response body: HTTP_%d - %w", res.StatusCode, err)
}
if res.StatusCode != 201 {

// Older version of foundriesio/estserver returned the status code 201, which is also required by older versions of foundriesio/fioconfig
// The spec requires status code 200.
if res.StatusCode != 200 && res.StatusCode != 201 {
return fmt.Errorf("Unable to obtain new certificate: HTTP_%d - %s", res.StatusCode, string(buf))
}
ct := res.Header.Get("content-type")
if ct != "application/pkcs7-mime" {
if !strings.HasPrefix(ct, "application/pkcs7-mime") {
return fmt.Errorf("Unexpected content-type return in certificate response: %s", ct)
}

estCert, err := decodeEstResponse(string(buf))
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion transport/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func httpDoOnce(client *http.Client, method, url string, headers map[string]stri
req.Header.Add(k, v)
}
if req.Header.Get("User-Agent") == "" {
req.Header.Add("User-Agent", "fioconfig-client/2")
req.Header.Add("User-Agent", "fioconfig-client/3")
}
if req.Header.Get("Content-Type") == "" {
req.Header.Add("Content-Type", "application/json")
Expand Down
Loading