func init() { bytes, err := hex.DecodeString(OCSPResponseHex) if err != nil { panic(err) } OCSPResponseBytes = bytes OCSPResponse, err = ocsp.ParseResponse(bytes, nil) if err != nil { panic(err) } }
func (s *stapler) getOCSPResponse(server string, request []byte, issuer *x509.Certificate) (*ocsp.Response, []byte, error) { httpReq, err := http.NewRequest("POST", server, bytes.NewReader(request)) httpReq.Header.Add("Content-Type", "application/ocsp-request") httpReq.Header.Add("Accept", "application/ocsp-response") resp, err := s.client.Do(httpReq) if err != nil { return nil, nil, err } body, err := ioutil.ReadAll(resp.Body) resp.Body.Close() re, err := ocsp.ParseResponse(body, issuer) if err != nil { return nil, nil, err } return re, body, nil }