@@ -263,74 +263,6 @@ func (b *keyfactorBackend) generateCSR(cn string, ip_sans []string, dns_sans []s
263263 return csrBuf .String (), x509 .MarshalPKCS1PrivateKey (keyBytes )
264264}
265265
266- // func fetchCertFromKeyfactor(ctx context.Context, req *logical.Request, b *keyfactorBackend, kfCertId string, includeChain bool) (string, error) {
267- // config, err := b.fetchConfig(ctx, req.Storage)
268- // if err != nil {
269- // return "", err
270- // }
271- // if config == nil {
272- // return "", errors.New("unable to load configuration")
273- // }
274-
275- // // get the client
276- // client, err := b.getClient(ctx, req.Storage)
277- // if err != nil {
278- // b.Logger().Error("unable to create the http client")
279- // }
280- // // This is only needed when running as a vault extension
281- // b.Logger().Debug("Closing idle connections")
282- // client.httpClient.CloseIdleConnections()
283-
284- // include := "false"
285- // if includeChain {
286- // include = "true"
287- // }
288-
289- // // Build request
290- // url := config.KeyfactorUrl + "Certificates/Download"
291- // b.Logger().Debug("url: " + url)
292- // bodyContent := fmt.Sprintf(`{"CertID": %s, "IncludeChain": %s, "ChainOrder": "endentityfirst" }`, kfCertId, include)
293- // payload := strings.NewReader(bodyContent)
294- // b.Logger().Debug("body: " + bodyContent)
295- // httpReq, err := http.NewRequest("POST", url, payload)
296- // if err != nil {
297- // b.Logger().Info("Error forming request: {{err}}", err)
298- // }
299- // httpReq.Header.Add("x-keyfactor-requested-with", "APIClient")
300- // httpReq.Header.Add("content-type", "application/json")
301- // httpReq.Header.Add("x-certificateformat", "PEM")
302-
303- // // Send request and check status
304- // b.Logger().Debug("About to connect to " + config.KeyfactorUrl + "for cert retrieval")
305- // res, err := client.httpClient.Do(httpReq)
306- // if err != nil {
307- // b.Logger().Info("failed getting cert: {{err}}", err)
308- // return "", err
309- // }
310- // if res.StatusCode != 200 {
311- // b.Logger().Error("request failed: server returned" + fmt.Sprint(res.StatusCode))
312- // b.Logger().Error("Error response = " + fmt.Sprint(res.Body))
313- // return "", fmt.Errorf("error downloading certificate. returned status = %d\n ", res.StatusCode)
314- // }
315-
316- // // Read response and return certificate and key
317- // defer res.Body.Close()
318-
319- // body, err := io.ReadAll(res.Body)
320- // if err != nil {
321- // b.Logger().Info("Error reading response: {{err}}", err)
322- // return "", err
323- // }
324-
325- // // Parse response
326- // var r KeyfactorCertDownloadResponse
327- // json.Unmarshal(body, &r)
328- // b.Logger().Debug("response = ", r)
329-
330- // return r.Content, nil
331-
332- // }
333-
334266// Allows fetching certificates from the backend; it handles the slightly
335267// separate pathing for CA and revoked certificates.
336268func fetchCertBySerial (ctx context.Context , req * logical.Request , prefix , serial string ) (* logical.StorageEntry , error ) {
0 commit comments