|
225 | 225 | #include <wolfssl/openssl/modes.h> |
226 | 226 | #include <wolfssl/openssl/fips_rand.h> |
227 | 227 | #include <wolfssl/openssl/kdf.h> |
| 228 | + #include <wolfssl/openssl/x509_vfy.h> |
228 | 229 | #ifdef OPENSSL_ALL |
229 | 230 | #include <wolfssl/openssl/txt_db.h> |
230 | 231 | #include <wolfssl/openssl/lhash.h> |
@@ -60207,6 +60208,54 @@ static int test_wolfSSL_X509_STORE_CTX_ex9(X509_STORE_test_data *testData) |
60207 | 60208 | sk_X509_free(trusted); |
60208 | 60209 | return EXPECT_RESULT(); |
60209 | 60210 | } |
| 60211 | + |
| 60212 | +static int test_wolfSSL_X509_STORE_CTX_ex10(X509_STORE_test_data *testData) |
| 60213 | +{ |
| 60214 | + EXPECT_DECLS; |
| 60215 | + X509_STORE* store = NULL; |
| 60216 | + X509_STORE_CTX* ctx = NULL; |
| 60217 | + STACK_OF(X509)* chain = NULL; |
| 60218 | + |
| 60219 | + /* Test case 10, ensure partial chain flag works */ |
| 60220 | + ExpectNotNull(store = X509_STORE_new()); |
| 60221 | + ExpectIntEQ(X509_STORE_add_cert(store, testData->x509CaInt), 1); |
| 60222 | + ExpectIntEQ(X509_STORE_add_cert(store, testData->x509CaInt2), 1); |
| 60223 | + ExpectNotNull(ctx = X509_STORE_CTX_new()); |
| 60224 | + ExpectIntEQ(X509_STORE_CTX_init(ctx, store, testData->x509Leaf, NULL), 1); |
| 60225 | + /* Fails because chain is incomplete */ |
| 60226 | + ExpectIntNE(X509_verify_cert(ctx), 1); |
| 60227 | + ExpectIntEQ(X509_STORE_set_flags(store, X509_V_FLAG_PARTIAL_CHAIN), 1); |
| 60228 | + /* Partial chain now OK */ |
| 60229 | + ExpectIntEQ(X509_verify_cert(ctx), 1); |
| 60230 | + ExpectNotNull(chain = X509_STORE_CTX_get_chain(ctx)); |
| 60231 | + X509_STORE_CTX_free(ctx); |
| 60232 | + X509_STORE_free(store); |
| 60233 | + return EXPECT_RESULT(); |
| 60234 | +} |
| 60235 | + |
| 60236 | +static int test_wolfSSL_X509_STORE_CTX_ex11(X509_STORE_test_data *testData) |
| 60237 | +{ |
| 60238 | + EXPECT_DECLS; |
| 60239 | + X509_STORE* store = NULL; |
| 60240 | + X509_STORE_CTX* ctx = NULL; |
| 60241 | + STACK_OF(X509)* chain = NULL; |
| 60242 | + |
| 60243 | + /* Test case 11, test partial chain flag on ctx itself */ |
| 60244 | + ExpectNotNull(store = X509_STORE_new()); |
| 60245 | + ExpectIntEQ(X509_STORE_add_cert(store, testData->x509CaInt), 1); |
| 60246 | + ExpectIntEQ(X509_STORE_add_cert(store, testData->x509CaInt2), 1); |
| 60247 | + ExpectNotNull(ctx = X509_STORE_CTX_new()); |
| 60248 | + ExpectIntEQ(X509_STORE_CTX_init(ctx, store, testData->x509Leaf, NULL), 1); |
| 60249 | + /* Fails because chain is incomplete */ |
| 60250 | + ExpectIntNE(X509_verify_cert(ctx), 1); |
| 60251 | + X509_STORE_CTX_set_flags(ctx, X509_V_FLAG_PARTIAL_CHAIN); |
| 60252 | + /* Partial chain now OK */ |
| 60253 | + ExpectIntEQ(X509_verify_cert(ctx), 1); |
| 60254 | + ExpectNotNull(chain = X509_STORE_CTX_get_chain(ctx)); |
| 60255 | + X509_STORE_CTX_free(ctx); |
| 60256 | + X509_STORE_free(store); |
| 60257 | + return EXPECT_RESULT(); |
| 60258 | +} |
60210 | 60259 | #endif |
60211 | 60260 |
|
60212 | 60261 | static int test_wolfSSL_X509_STORE_CTX_ex(void) |
@@ -60244,6 +60293,8 @@ static int test_wolfSSL_X509_STORE_CTX_ex(void) |
60244 | 60293 | ExpectIntEQ(test_wolfSSL_X509_STORE_CTX_ex7(&testData), 1); |
60245 | 60294 | ExpectIntEQ(test_wolfSSL_X509_STORE_CTX_ex8(&testData), 1); |
60246 | 60295 | ExpectIntEQ(test_wolfSSL_X509_STORE_CTX_ex9(&testData), 1); |
| 60296 | + ExpectIntEQ(test_wolfSSL_X509_STORE_CTX_ex10(&testData), 1); |
| 60297 | + ExpectIntEQ(test_wolfSSL_X509_STORE_CTX_ex11(&testData), 1); |
60247 | 60298 |
|
60248 | 60299 | if(testData.x509Ca) { |
60249 | 60300 | X509_free(testData.x509Ca); |
|
0 commit comments