From 79f1ecf29f996666ab0d6c813204f6edfdfa3027 Mon Sep 17 00:00:00 2001 From: John Wood Date: Fri, 1 Jul 2022 13:41:01 -0700 Subject: [PATCH] Unconditionally add forward slash in OCSP GET requests (#282) --- lib/ocsp.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/ocsp.go b/lib/ocsp.go index 9bd3ba8..0fa1929 100644 --- a/lib/ocsp.go +++ b/lib/ocsp.go @@ -24,7 +24,6 @@ import ( "fmt" "io" "net/http" - "strings" "time" "github.com/fatih/color" @@ -176,11 +175,11 @@ func buildOCSPwithPOST(server string, encoded []byte) (*http.Request, error) { } func buildOCSPwithGET(server string, encoded []byte) (*http.Request, error) { - if !strings.HasSuffix(server, "/") { - server = server + "/" - } + // https://datatracker.ietf.org/doc/html/rfc6960#appendix-A.1 + // GET {url}/{url-encoding of base-64 encoding of the DER encoding of the OCSPRequest} + url := fmt.Sprintf("%s/%s", server, base64.StdEncoding.EncodeToString(encoded)) - req, err := http.NewRequest("GET", server+base64.StdEncoding.EncodeToString(encoded), nil) + req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err }