Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Revert URL encoding OCSP GET fix #18938 into release/1.12.x #19069

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
8 changes: 1 addition & 7 deletions builtin/logical/pki/path_ocsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"io"
"math/big"
"net/http"
"net/url"
"time"

"github.com/hashicorp/vault/sdk/helper/errutil"
Expand Down Expand Up @@ -216,12 +215,7 @@ func fetchDerEncodedRequest(request *logical.Request, data *framework.FieldData)
return nil, errors.New("request is too large")
}

unescapedBase64, err := url.QueryUnescape(base64Req)
if err != nil {
return nil, fmt.Errorf("failed to unescape base64 string: %w", err)
}

return base64.StdEncoding.DecodeString(unescapedBase64)
return base64.StdEncoding.DecodeString(base64Req)
case logical.UpdateOperation:
// POST bodies should contain the binary form of the DER request.
// NOTE: Writing an empty update request to Vault causes a nil request.HTTPRequest, and that object
Expand Down
5 changes: 2 additions & 3 deletions builtin/logical/pki/path_ocsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -441,7 +440,7 @@ func TestOcsp_HigherLevel(t *testing.T) {
require.Equal(t, certToRevoke.SerialNumber, ocspResp.SerialNumber)

// Test OCSP Get request for ocsp
urlEncoded := url.QueryEscape(base64.StdEncoding.EncodeToString(ocspReq))
urlEncoded := base64.StdEncoding.EncodeToString(ocspReq)
ocspGetReq := client.NewRequest(http.MethodGet, "/v1/pki/ocsp/"+urlEncoded)
ocspGetReq.Headers.Set("Content-Type", "application/ocsp-request")
rawResp, err = client.RawRequest(ocspGetReq)
Expand Down Expand Up @@ -684,7 +683,7 @@ func sendOcspRequest(t *testing.T, b *backend, s logical.Storage, getOrPost stri
}

func sendOcspGetRequest(b *backend, s logical.Storage, ocspRequest []byte) (*logical.Response, error) {
urlEncoded := url.QueryEscape(base64.StdEncoding.EncodeToString(ocspRequest))
urlEncoded := base64.StdEncoding.EncodeToString(ocspRequest)
return CBRead(b, s, "ocsp/"+urlEncoded)
}

Expand Down
3 changes: 3 additions & 0 deletions changelog/19037.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
secrets/pki: Revert fix for PR [18938](https://github.com/hashicorp/vault/pull/18938)
```