...

Source file src/github.com/letsencrypt/boulder/wfe2/test_aia.go

Documentation: github.com/letsencrypt/boulder/wfe2

     1  //go:build integration
     2  
     3  package wfe2
     4  
     5  import (
     6  	"context"
     7  	"net/http"
     8  	"strconv"
     9  
    10  	"github.com/letsencrypt/boulder/issuance"
    11  	"github.com/letsencrypt/boulder/probs"
    12  	"github.com/letsencrypt/boulder/web"
    13  )
    14  
    15  // Issuer returns the Issuer Cert identified by the path (its IssuerNameID).
    16  // Used by integration tests to handle requests for the AIA Issuer URL.
    17  func (wfe *WebFrontEndImpl) Issuer(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) {
    18  	idStr := request.URL.Path
    19  	id, err := strconv.ParseInt(idStr, 10, 64)
    20  	if err != nil {
    21  		wfe.sendError(response, logEvent, probs.Malformed("Issuer ID must be an integer"), err)
    22  		return
    23  	}
    24  
    25  	issuer, ok := wfe.issuerCertificates[issuance.IssuerNameID(id)]
    26  	if !ok {
    27  		wfe.sendError(response, logEvent, probs.NotFound("Issuer ID did not match any known issuer"), nil)
    28  		return
    29  	}
    30  
    31  	response.Header().Set("Content-Type", "application/pkix-cert")
    32  	response.WriteHeader(http.StatusOK)
    33  	_, err = response.Write(issuer.Certificate.Raw)
    34  	if err != nil {
    35  		wfe.log.Warningf("Could not write response: %s", err)
    36  	}
    37  }
    38  

View as plain text