• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 12670279516

08 Jan 2025 12:10PM UTC coverage: 91.22% (-0.03%) from 91.254%
12670279516

push

github

web-flow
Merge pull request #4536 from Rohde-Schwarz/fix/ocsp_with_multiple_certs

FIX: loading pinned certificates from OCSP responses

93383 of 102371 relevant lines covered (91.22%)

11467570.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.42
/src/tests/test_ocsp.cpp
1
/*
2
* (C) 2016 Jack Lloyd
3
* (C) 2022 René Meusel, Rohde & Schwarz Cybersecurity
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7

8
#include "tests.h"
9

10
#if defined(BOTAN_HAS_OCSP)
11
   #include <botan/certstor.h>
12
   #include <botan/ocsp.h>
13
   #include <botan/x509path.h>
14
   #include <botan/internal/calendar.h>
15
   #include <fstream>
16
#endif
17

18
namespace Botan_Tests {
19

20
#if defined(BOTAN_HAS_OCSP) && defined(BOTAN_HAS_RSA) && defined(BOTAN_HAS_EMSA_PKCS1) && \
21
   defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
22

23
class OCSP_Tests final : public Test {
×
24
   private:
25
      static Botan::X509_Certificate load_test_X509_cert(const std::string& path) {
23✔
26
         return Botan::X509_Certificate(Test::data_file(path));
46✔
27
      }
28

29
      static Botan::OCSP::Response load_test_OCSP_resp(const std::string& path) {
9✔
30
         return Botan::OCSP::Response(Test::read_binary_data_file(path));
27✔
31
      }
32

33
      static Test::Result test_response_parsing() {
1✔
34
         Test::Result result("OCSP response parsing");
1✔
35

36
         // Simple parsing tests
37
         const std::vector<std::string> ocsp_input_paths = {
1✔
38
            "x509/ocsp/resp1.der", "x509/ocsp/resp2.der", "x509/ocsp/resp3.der"};
1✔
39

40
         for(const std::string& ocsp_input_path : ocsp_input_paths) {
4✔
41
            try {
3✔
42
               Botan::OCSP::Response resp(Test::read_binary_data_file(ocsp_input_path));
6✔
43
               result.confirm("parsing was successful", resp.status() == Botan::OCSP::Response_Status_Code::Successful);
6✔
44
               result.test_success("Parsed input " + ocsp_input_path);
3✔
45
            } catch(Botan::Exception& e) {
3✔
46
               result.test_failure("Parsing failed", e.what());
×
47
            }
×
48
         }
49

50
         Botan::OCSP::Response resp(
1✔
51
            Test::read_binary_data_file("x509/ocsp/patrickschmidt_ocsp_try_later_wrong_sig.der"));
3✔
52
         result.confirm("parsing exposes correct status code",
2✔
53
                        resp.status() == Botan::OCSP::Response_Status_Code::Try_Later);
1✔
54

55
         return result;
1✔
56
      }
1✔
57

58
      static Test::Result test_response_certificate_access() {
1✔
59
         Test::Result result("OCSP response certificate access");
1✔
60

61
         try {
1✔
62
            Botan::OCSP::Response resp1(Test::read_binary_data_file("x509/ocsp/resp1.der"));
3✔
63
            const auto& certs1 = resp1.certificates();
1✔
64
            if(result.test_eq("Expected count of certificates", certs1.size(), 1)) {
1✔
65
               const auto& cert = certs1.front();
1✔
66
               const Botan::X509_DN expected_dn(
1✔
67
                  {std::make_pair("X520.CommonName", "Symantec Class 3 EV SSL CA - G3 OCSP Responder")});
3✔
68
               const bool matches = cert.subject_dn() == expected_dn;
1✔
69
               result.test_eq("CN matches expected", matches, true);
1✔
70
            }
1✔
71

72
            Botan::OCSP::Response resp2(Test::read_binary_data_file("x509/ocsp/resp2.der"));
3✔
73
            const auto& certs2 = resp2.certificates();
1✔
74
            result.test_eq("Expect no certificates", certs2.size(), 0);
1✔
75
         } catch(Botan::Exception& e) {
1✔
76
            result.test_failure("Parsing failed", e.what());
×
77
         }
×
78

79
         return result;
1✔
80
      }
1✔
81

82
      static Test::Result test_request_encoding() {
1✔
83
         Test::Result result("OCSP request encoding");
1✔
84

85
         const Botan::X509_Certificate end_entity(Test::data_file("x509/ocsp/gmail.pem"));
2✔
86
         const Botan::X509_Certificate issuer(Test::data_file("x509/ocsp/google_g2.pem"));
2✔
87

88
         try {
1✔
89
            const Botan::OCSP::Request bogus(end_entity, issuer);
1✔
90
            result.test_failure("Bad arguments (swapped end entity, issuer) accepted");
×
91
         } catch(Botan::Invalid_Argument&) {
1✔
92
            result.test_success("Bad arguments rejected");
1✔
93
         }
1✔
94

95
         const std::string expected_request =
1✔
96
            "ME4wTKADAgEAMEUwQzBBMAkGBSsOAwIaBQAEFPLgavmFih2NcJtJGSN6qbUaKH5kBBRK3QYWG7z2aLV29YG2u2IaulqBLwIIQkg+DF+RYMY=";
1✔
97

98
         const Botan::OCSP::Request req1(issuer, end_entity);
1✔
99
         result.test_eq("Encoded OCSP request", req1.base64_encode(), expected_request);
2✔
100

101
         const Botan::OCSP::Request req2(issuer, BigInt::from_bytes(end_entity.serial_number()));
1✔
102
         result.test_eq("Encoded OCSP request", req2.base64_encode(), expected_request);
2✔
103

104
         return result;
2✔
105
      }
2✔
106

107
      static Test::Result test_response_find_signing_certificate() {
1✔
108
         Test::Result result("OCSP response finding signature certificates");
1✔
109

110
         const std::optional<Botan::X509_Certificate> nullopt_cert;
1✔
111

112
         // OCSP response is signed by the issuing CA itself
113
         auto randombit_ocsp = load_test_OCSP_resp("x509/ocsp/randombit_ocsp.der");
1✔
114
         auto randombit_ca = load_test_X509_cert("x509/ocsp/letsencrypt.pem");
1✔
115

116
         // OCSP response is signed by an authorized responder certificate
117
         // issued by the issuing CA and embedded in the response
118
         auto bdr_ocsp = load_test_OCSP_resp("x509/ocsp/bdr-ocsp-resp.der");
1✔
119
         auto bdr_responder = load_test_X509_cert("x509/ocsp/bdr-ocsp-responder.pem");
1✔
120
         auto bdr_ca = load_test_X509_cert("x509/ocsp/bdr-int.pem");
1✔
121

122
         // The response in bdr_ocsp contains two certificates
123
         if(result.test_eq("both certificates found", bdr_ocsp.certificates().size(), 2)) {
1✔
124
            result.test_eq("first cert in response",
2✔
125
                           bdr_ocsp.certificates()[0].subject_info("X520.CommonName").at(0),
3✔
126
                           "D-TRUST OCSP 4 2-2 EV 2016");
127
            result.test_eq("second cert in response",
3✔
128
                           bdr_ocsp.certificates()[1].subject_info("X520.CommonName").at(0),
3✔
129
                           "D-TRUST CA 2-2 EV 2016");
130
         }
131

132
         // Dummy OCSP response is not signed at all
133
         auto dummy_ocsp = Botan::OCSP::Response(Botan::Certificate_Status_Code::OCSP_SERVER_NOT_AVAILABLE);
1✔
134

135
         // OCSP response is signed by 3rd party responder certificate that is
136
         // not included in the OCSP response itself
137
         // See `src/scripts/randombit_ocsp_forger.sh` for a helper script to recreate those.
138
         auto randombit_alt_resp_ocsp = load_test_OCSP_resp("x509/ocsp/randombit_ocsp_forged_valid_nocerts.der");
1✔
139
         auto randombit_alt_resp_cert = load_test_X509_cert("x509/ocsp/randombit_ocsp_forged_responder.pem");
1✔
140

141
         result.test_is_eq("Dummy has no signing certificate",
2✔
142
                           dummy_ocsp.find_signing_certificate(Botan::X509_Certificate()),
2✔
143
                           nullopt_cert);
144

145
         result.test_is_eq("CA is returned as signing certificate",
3✔
146
                           randombit_ocsp.find_signing_certificate(randombit_ca),
1✔
147
                           std::optional(randombit_ca));
1✔
148
         result.test_is_eq("No signer certificate is returned when signer couldn't be determined",
2✔
149
                           randombit_ocsp.find_signing_certificate(bdr_ca),
1✔
150
                           nullopt_cert);
151

152
         result.test_is_eq("Delegated responder certificate is returned for further validation",
3✔
153
                           bdr_ocsp.find_signing_certificate(bdr_ca),
1✔
154
                           std::optional(bdr_responder));
1✔
155

156
         result.test_is_eq("Delegated responder without stapled certs does not find signer without user-provided certs",
2✔
157
                           randombit_alt_resp_ocsp.find_signing_certificate(randombit_ca),
1✔
158
                           nullopt_cert);
159
         auto trusted_responders = std::make_unique<Botan::Certificate_Store_In_Memory>(randombit_alt_resp_cert);
1✔
160
         result.test_is_eq("Delegated responder returns user-provided cert",
3✔
161
                           randombit_alt_resp_ocsp.find_signing_certificate(randombit_ca, trusted_responders.get()),
2✔
162
                           std::optional(randombit_alt_resp_cert));
1✔
163

164
         return result;
2✔
165
      }
1✔
166

167
      static Test::Result test_response_verification_with_next_update_without_max_age() {
1✔
168
         Test::Result result("OCSP request check with next_update w/o max_age");
1✔
169

170
         auto ee = load_test_X509_cert("x509/ocsp/randombit.pem");
1✔
171
         auto ca = load_test_X509_cert("x509/ocsp/letsencrypt.pem");
1✔
172
         auto trust_root = load_test_X509_cert("x509/ocsp/geotrust.pem");
1✔
173

174
         const std::vector<Botan::X509_Certificate> cert_path = {ee, ca, trust_root};
4✔
175

176
         auto ocsp = load_test_OCSP_resp("x509/ocsp/randombit_ocsp.der");
1✔
177

178
         Botan::Certificate_Store_In_Memory certstore;
1✔
179
         certstore.add_certificate(trust_root);
1✔
180

181
         auto check_ocsp = [&](const std::chrono::system_clock::time_point valid_time,
5✔
182
                               const Botan::Certificate_Status_Code expected) {
183
            const auto ocsp_status = Botan::PKIX::check_ocsp(
8✔
184
               cert_path, {ocsp}, {&certstore}, valid_time, Botan::Path_Validation_Restrictions());
16✔
185

186
            return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
8✔
187
                   result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
12✔
188
                   result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
28✔
189
                                  ocsp_status[0].contains(expected));
12✔
190
         };
8✔
191

192
         check_ocsp(Botan::calendar_point(2016, 11, 11, 12, 30, 0).to_std_timepoint(),
1✔
193
                    Botan::Certificate_Status_Code::OCSP_NOT_YET_VALID);
194
         check_ocsp(Botan::calendar_point(2016, 11, 18, 12, 30, 0).to_std_timepoint(),
1✔
195
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
196
         check_ocsp(Botan::calendar_point(2016, 11, 20, 8, 30, 0).to_std_timepoint(),
1✔
197
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
198
         check_ocsp(Botan::calendar_point(2016, 11, 28, 8, 30, 0).to_std_timepoint(),
1✔
199
                    Botan::Certificate_Status_Code::OCSP_HAS_EXPIRED);
200

201
         return result;
1✔
202
      }
2✔
203

204
      static Test::Result test_response_verification_with_next_update_with_max_age() {
1✔
205
         Test::Result result("OCSP request check with next_update with max_age");
1✔
206

207
         auto ee = load_test_X509_cert("x509/ocsp/randombit.pem");
1✔
208
         auto ca = load_test_X509_cert("x509/ocsp/letsencrypt.pem");
1✔
209
         auto trust_root = load_test_X509_cert("x509/ocsp/geotrust.pem");
1✔
210

211
         const std::vector<Botan::X509_Certificate> cert_path = {ee, ca, trust_root};
4✔
212

213
         auto ocsp = load_test_OCSP_resp("x509/ocsp/randombit_ocsp.der");
1✔
214

215
         Botan::Certificate_Store_In_Memory certstore;
1✔
216
         certstore.add_certificate(trust_root);
1✔
217

218
         // Some arbitrary time within the validity period of the test certs
219
         const auto max_age = std::chrono::minutes(59);
1✔
220

221
         auto check_ocsp = [&](const std::chrono::system_clock::time_point valid_time,
5✔
222
                               const Botan::Certificate_Status_Code expected) {
223
            Botan::Path_Validation_Restrictions pvr(false, 110, false, max_age);
4✔
224
            const auto ocsp_status = Botan::PKIX::check_ocsp(cert_path, {ocsp}, {&certstore}, valid_time, pvr);
12✔
225

226
            return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
8✔
227
                   result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
12✔
228
                   result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
28✔
229
                                  ocsp_status[0].contains(expected));
12✔
230
         };
8✔
231

232
         check_ocsp(Botan::calendar_point(2016, 11, 11, 12, 30, 0).to_std_timepoint(),
1✔
233
                    Botan::Certificate_Status_Code::OCSP_NOT_YET_VALID);
234
         check_ocsp(Botan::calendar_point(2016, 11, 18, 12, 30, 0).to_std_timepoint(),
1✔
235
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
236
         check_ocsp(Botan::calendar_point(2016, 11, 20, 8, 30, 0).to_std_timepoint(),
1✔
237
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
238
         check_ocsp(Botan::calendar_point(2016, 11, 28, 8, 30, 0).to_std_timepoint(),
1✔
239
                    Botan::Certificate_Status_Code::OCSP_HAS_EXPIRED);
240

241
         return result;
1✔
242
      }
2✔
243

244
      static Test::Result test_response_verification_without_next_update_with_max_age() {
1✔
245
         Test::Result result("OCSP request check w/o next_update with max_age");
1✔
246

247
         auto ee = load_test_X509_cert("x509/ocsp/patrickschmidt.pem");
1✔
248
         auto ca = load_test_X509_cert("x509/ocsp/bdrive_encryption.pem");
1✔
249
         auto trust_root = load_test_X509_cert("x509/ocsp/bdrive_root.pem");
1✔
250

251
         const std::vector<Botan::X509_Certificate> cert_path = {ee, ca, trust_root};
4✔
252

253
         auto ocsp = load_test_OCSP_resp("x509/ocsp/patrickschmidt_ocsp.der");
1✔
254

255
         Botan::Certificate_Store_In_Memory certstore;
1✔
256
         certstore.add_certificate(trust_root);
1✔
257

258
         // Some arbitrary time within the validity period of the test certs
259
         const auto max_age = std::chrono::minutes(59);
1✔
260

261
         auto check_ocsp = [&](const std::chrono::system_clock::time_point valid_time,
4✔
262
                               const Botan::Certificate_Status_Code expected) {
263
            Botan::Path_Validation_Restrictions pvr(false, 110, false, max_age);
3✔
264
            const auto ocsp_status = Botan::PKIX::check_ocsp(cert_path, {ocsp}, {&certstore}, valid_time, pvr);
9✔
265

266
            return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
6✔
267
                   result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
9✔
268
                   result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
21✔
269
                                  ocsp_status[0].contains(expected));
9✔
270
         };
6✔
271

272
         check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 0, 0).to_std_timepoint(),
1✔
273
                    Botan::Certificate_Status_Code::OCSP_NOT_YET_VALID);
274
         check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 30, 0).to_std_timepoint(),
1✔
275
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
276
         check_ocsp(Botan::calendar_point(2019, 5, 28, 8, 0, 0).to_std_timepoint(),
1✔
277
                    Botan::Certificate_Status_Code::OCSP_IS_TOO_OLD);
278

279
         return result;
1✔
280
      }
2✔
281

282
      static Test::Result test_response_verification_without_next_update_without_max_age() {
1✔
283
         Test::Result result("OCSP request check w/o next_update w/o max_age");
1✔
284

285
         auto ee = load_test_X509_cert("x509/ocsp/patrickschmidt.pem");
1✔
286
         auto ca = load_test_X509_cert("x509/ocsp/bdrive_encryption.pem");
1✔
287
         auto trust_root = load_test_X509_cert("x509/ocsp/bdrive_root.pem");
1✔
288

289
         const std::vector<Botan::X509_Certificate> cert_path = {ee, ca, trust_root};
4✔
290

291
         auto ocsp = load_test_OCSP_resp("x509/ocsp/patrickschmidt_ocsp.der");
1✔
292

293
         Botan::Certificate_Store_In_Memory certstore;
1✔
294
         certstore.add_certificate(trust_root);
1✔
295

296
         auto check_ocsp = [&](const std::chrono::system_clock::time_point valid_time,
4✔
297
                               const Botan::Certificate_Status_Code expected) {
298
            const auto ocsp_status = Botan::PKIX::check_ocsp(
6✔
299
               cert_path, {ocsp}, {&certstore}, valid_time, Botan::Path_Validation_Restrictions());
12✔
300

301
            return result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1) &&
6✔
302
                   result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1) &&
9✔
303
                   result.confirm(std::string("Status: '") + Botan::to_string(expected) + "'",
21✔
304
                                  ocsp_status[0].contains(expected));
9✔
305
         };
6✔
306

307
         check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 0, 0).to_std_timepoint(),
1✔
308
                    Botan::Certificate_Status_Code::OCSP_NOT_YET_VALID);
309
         check_ocsp(Botan::calendar_point(2019, 5, 28, 7, 30, 0).to_std_timepoint(),
1✔
310
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
311
         check_ocsp(Botan::calendar_point(2019, 5, 28, 8, 0, 0).to_std_timepoint(),
1✔
312
                    Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
313

314
         return result;
1✔
315
      }
2✔
316

317
      static Test::Result test_response_verification_softfail() {
1✔
318
         Test::Result result("OCSP request softfail check");
1✔
319

320
         auto ee = load_test_X509_cert("x509/ocsp/randombit.pem");
1✔
321
         auto ca = load_test_X509_cert("x509/ocsp/letsencrypt.pem");
1✔
322
         auto trust_root = load_test_X509_cert("x509/ocsp/geotrust.pem");
1✔
323

324
         const std::vector<Botan::X509_Certificate> cert_path = {ee, ca, trust_root};
4✔
325

326
         Botan::OCSP::Response ocsp(Botan::Certificate_Status_Code::OCSP_NO_REVOCATION_URL);
1✔
327

328
         Botan::Certificate_Store_In_Memory certstore;
1✔
329
         certstore.add_certificate(trust_root);
1✔
330

331
         // Some arbitrary time within the validity period of the test certs
332
         const auto valid_time = Botan::calendar_point(2016, 11, 20, 8, 30, 0).to_std_timepoint();
1✔
333
         const auto ocsp_status =
1✔
334
            Botan::PKIX::check_ocsp(cert_path, {ocsp}, {&certstore}, valid_time, Botan::Path_Validation_Restrictions());
4✔
335

336
         if(result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1)) {
1✔
337
            if(result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1)) {
1✔
338
               result.test_gt(
3✔
339
                  "Status warning", ocsp_status[0].count(Botan::Certificate_Status_Code::OCSP_NO_REVOCATION_URL), 0);
1✔
340
            }
341
         }
342

343
         return result;
1✔
344
      }
3✔
345

346
   #if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
347
      static Test::Result test_online_request() {
1✔
348
         Test::Result result("OCSP online check");
1✔
349

350
         auto cert = load_test_X509_cert("x509/ocsp/digicert-ecdsa-int.pem");
1✔
351
         auto trust_root = load_test_X509_cert("x509/ocsp/digicert-root.pem");
1✔
352

353
         const std::vector<Botan::X509_Certificate> cert_path = {cert, trust_root};
3✔
354

355
         Botan::Certificate_Store_In_Memory certstore;
1✔
356
         certstore.add_certificate(trust_root);
1✔
357

358
         const auto ocsp_timeout = std::chrono::milliseconds(3000);
1✔
359
         const auto now = std::chrono::system_clock::now();
1✔
360
         auto ocsp_status = Botan::PKIX::check_ocsp_online(
1✔
361
            cert_path, {&certstore}, now, ocsp_timeout, Botan::Path_Validation_Restrictions());
2✔
362

363
         if(result.test_eq("Expected size of ocsp_status", ocsp_status.size(), 1)) {
1✔
364
            if(result.test_eq("Expected size of ocsp_status[0]", ocsp_status[0].size(), 1)) {
1✔
365
               const bool status_good = ocsp_status[0].contains(Botan::Certificate_Status_Code::OCSP_RESPONSE_GOOD);
1✔
366
               const bool server_not_found =
1✔
367
                  ocsp_status[0].contains(Botan::Certificate_Status_Code::OCSP_SERVER_NOT_AVAILABLE);
1✔
368
               result.confirm("Expected status", status_good || server_not_found);
2✔
369
            }
370
         }
371

372
         return result;
1✔
373
      }
2✔
374
   #endif
375

376
      static Test::Result test_response_verification_with_additionally_trusted_responder() {
1✔
377
         Test::Result result("OCSP response with user-defined (additional) responder certificate");
1✔
378

379
         // OCSP response is signed by 3rd party responder certificate that is
380
         // not included in the OCSP response itself
381
         // See `src/scripts/randombit_ocsp_forger.sh` for a helper script to recreate those.
382
         auto ocsp = load_test_OCSP_resp("x509/ocsp/randombit_ocsp_forged_valid_nocerts.der");
1✔
383
         auto responder = load_test_X509_cert("x509/ocsp/randombit_ocsp_forged_responder.pem");
1✔
384
         auto ca = load_test_X509_cert("x509/ocsp/letsencrypt.pem");
1✔
385

386
         std::optional<Botan::X509_Certificate> nullopt_cert;
1✔
387

388
         Botan::Certificate_Store_In_Memory trusted_responders;
1✔
389

390
         // without providing the 3rd party responder certificate no issuer will be found
391
         result.test_is_eq("cannot find signing certificate without trusted responders",
2✔
392
                           ocsp.find_signing_certificate(ca),
1✔
393
                           nullopt_cert);
394
         result.test_is_eq("cannot find signing certificate without additional help",
2✔
395
                           ocsp.find_signing_certificate(ca, &trusted_responders),
1✔
396
                           nullopt_cert);
397

398
         // add the 3rd party responder certificate to the list of trusted OCSP responder certs
399
         // to find the issuer certificate of this response
400
         trusted_responders.add_certificate(responder);
1✔
401
         result.test_is_eq("the responder certificate is returned when it is trusted",
3✔
402
                           ocsp.find_signing_certificate(ca, &trusted_responders),
1✔
403
                           std::optional(responder));
1✔
404

405
         result.test_is_eq("the responder's signature checks out",
1✔
406
                           ocsp.verify_signature(responder),
1✔
407
                           Botan::Certificate_Status_Code::OCSP_SIGNATURE_OK);
1✔
408

409
         return result;
1✔
410
      }
1✔
411

412
      static Test::Result test_responder_cert_with_nocheck_extension() {
1✔
413
         Test::Result result("BDr's OCSP response contains certificate featuring NoCheck extension");
1✔
414

415
         auto ocsp = load_test_OCSP_resp("x509/ocsp/bdr-ocsp-resp.der");
1✔
416
         const bool contains_cert_with_nocheck =
1✔
417
            std::find_if(ocsp.certificates().cbegin(), ocsp.certificates().cend(), [](const auto& cert) {
1✔
418
               return cert.v3_extensions().extension_set(Botan::OID::from_string("PKIX.OCSP.NoCheck"));
1✔
419
            }) != ocsp.certificates().end();
1✔
420

421
         result.confirm("Contains NoCheck extension", contains_cert_with_nocheck);
2✔
422

423
         return result;
1✔
424
      }
1✔
425

426
   public:
427
      std::vector<Test::Result> run() override {
1✔
428
         std::vector<Test::Result> results;
1✔
429

430
         results.push_back(test_request_encoding());
2✔
431
         results.push_back(test_response_parsing());
2✔
432
         results.push_back(test_response_certificate_access());
2✔
433
         results.push_back(test_response_find_signing_certificate());
2✔
434
         results.push_back(test_response_verification_with_next_update_without_max_age());
2✔
435
         results.push_back(test_response_verification_with_next_update_with_max_age());
2✔
436
         results.push_back(test_response_verification_without_next_update_with_max_age());
2✔
437
         results.push_back(test_response_verification_without_next_update_without_max_age());
2✔
438
         results.push_back(test_response_verification_softfail());
2✔
439
         results.push_back(test_response_verification_with_additionally_trusted_responder());
2✔
440
         results.push_back(test_responder_cert_with_nocheck_extension());
2✔
441

442
   #if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS)
443
         if(Test::options().run_online_tests()) {
1✔
444
            results.push_back(test_online_request());
2✔
445
         }
446
   #endif
447

448
         return results;
1✔
449
      }
×
450
};
451

452
BOTAN_REGISTER_TEST("x509", "ocsp", OCSP_Tests);
453

454
#endif
455

456
}  // namespace Botan_Tests
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc