@@ -10,7 +10,6 @@ import (
1010 "encoding/pem"
1111 "fmt"
1212 "io"
13- "io/ioutil"
1413 "net/http"
1514 "os"
1615 "path/filepath"
@@ -122,6 +121,7 @@ func (bh *BaseHandler) ApiRequestCertificateHandler(w http.ResponseWriter, r *ht
122121
123122 w .Header ().Add (global .CertificateLocationHeader , fmt .Sprintf (bh .Config .ServerHost + global .CertificateObtainPath , sn ))
124123 w .Header ().Add (global .PrivateKeyLocationHandler , fmt .Sprintf (bh .Config .ServerHost + global .PrivateKeyObtainPath , sn ))
124+ w .WriteHeader (http .StatusCreated )
125125}
126126
127127// ApiRequestCertificateWithCSRHandler handles a client's request for a new certificate,
@@ -147,16 +147,14 @@ func (bh *BaseHandler) ApiRequestCertificateWithCSRHandler(w http.ResponseWriter
147147 return
148148 }
149149
150- csrBytes , err := ioutil .ReadAll (r .Body )
150+ csrBytes , err := io .ReadAll (r .Body )
151151 if err != nil {
152152 logger .Debugf ("could not read request body: %s" , err .Error ())
153153 http .Error (w , "malformed http request" , http .StatusBadRequest )
154154 return
155155 }
156156
157- p , _ := pem .Decode (csrBytes )
158-
159- csr , err := x509 .ParseCertificateRequest (p .Bytes )
157+ csr , err := x509 .ParseCertificateRequest (csrBytes )
160158 if err != nil {
161159 logger .Debugf ("could not parse certificate signing request: %s" , err .Error ())
162160 http .Error (w , "malformed certificate signing request" , http .StatusBadRequest )
@@ -216,6 +214,8 @@ func (bh *BaseHandler) ApiRequestCertificateWithCSRHandler(w http.ResponseWriter
216214 }
217215
218216 w .Header ().Add (global .CertificateLocationHeader , fmt .Sprintf (bh .Config .ServerHost + global .CertificateObtainPath , sn ))
217+ // private key location header intentionally omitted because it's not needed
218+
219219 w .WriteHeader (http .StatusCreated )
220220}
221221
0 commit comments