VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.3/test/confdump.c@ 102797

Last change on this file since 102797 was 101211, checked in by vboxsync, 15 months ago

openssl-3.1.3: Applied and adjusted our OpenSSL changes to 3.1.2. bugref:10527

File size: 1.4 KB
Line 
1/*
2 * Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#include <stdio.h>
11#include <string.h>
12#include <openssl/bio.h>
13#include <openssl/conf.h>
14#include <openssl/safestack.h>
15#include <openssl/err.h>
16
17static void dump_section(const char *name, const CONF *cnf)
18{
19 STACK_OF(CONF_VALUE) *sect = NCONF_get_section(cnf, name);
20 int i;
21
22 printf("[ %s ]\n", name);
23 for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
24 CONF_VALUE *cv = sk_CONF_VALUE_value(sect, i);
25
26 printf("%s = %s\n", cv->name, cv->value);
27 }
28}
29
30int main(int argc, char **argv)
31{
32 long eline;
33 CONF *conf = NCONF_new(NCONF_default());
34 int ret = 1;
35 STACK_OF(OPENSSL_CSTRING) *section_names = NULL;
36
37 if (conf != NULL && NCONF_load(conf, argv[1], &eline)) {
38 int i;
39
40 section_names = NCONF_get_section_names(conf);
41 for (i = 0; i < sk_OPENSSL_CSTRING_num(section_names); i++) {
42 dump_section(sk_OPENSSL_CSTRING_value(section_names, i), conf);
43 }
44 sk_OPENSSL_CSTRING_free(section_names);
45 ret = 0;
46 } else {
47 ERR_print_errors_fp(stderr);
48 }
49 NCONF_free(conf);
50 return ret;
51}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette