diff options
author | schwarze <> | 2018-04-07 13:54:46 +0000 |
---|---|---|
committer | schwarze <> | 2018-04-07 13:54:46 +0000 |
commit | 4608af0736dc60b5c3961e69526d193a03fb7f16 (patch) | |
tree | 14abb85d50461bc29c2fc3bc58365dc8a2af5cbb /src/regress/lib/libcrypto/x509/x509name.c | |
parent | 51c043113484c53de869b645bf4515c05a75e519 (diff) | |
download | openbsd-4608af0736dc60b5c3961e69526d193a03fb7f16.tar.gz openbsd-4608af0736dc60b5c3961e69526d193a03fb7f16.tar.bz2 openbsd-4608af0736dc60b5c3961e69526d193a03fb7f16.zip |
test X509_NAME_add_entry_by_txt(3); feedback and OK jsing@
Diffstat (limited to 'src/regress/lib/libcrypto/x509/x509name.c')
-rw-r--r-- | src/regress/lib/libcrypto/x509/x509name.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/regress/lib/libcrypto/x509/x509name.c b/src/regress/lib/libcrypto/x509/x509name.c new file mode 100644 index 0000000000..4ff8ac6908 --- /dev/null +++ b/src/regress/lib/libcrypto/x509/x509name.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* $OpenBSD: x509name.c,v 1.1 2018/04/07 13:54:46 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <err.h> | ||
19 | #include <stdio.h> | ||
20 | |||
21 | #include <openssl/x509.h> | ||
22 | |||
23 | static void debug_print(X509_NAME *); | ||
24 | |||
25 | static void | ||
26 | debug_print(X509_NAME *name) | ||
27 | { | ||
28 | int loc; | ||
29 | |||
30 | for (loc = 0; loc < X509_NAME_entry_count(name); loc++) | ||
31 | printf("%d:", X509_NAME_get_entry(name, loc)->set); | ||
32 | putchar(' '); | ||
33 | X509_NAME_print_ex_fp(stdout, name, 0, XN_FLAG_SEP_CPLUS_SPC); | ||
34 | putchar('\n'); | ||
35 | } | ||
36 | |||
37 | int | ||
38 | main(void) | ||
39 | { | ||
40 | X509_NAME *name; | ||
41 | |||
42 | if ((name = X509_NAME_new()) == NULL) | ||
43 | err(1, NULL); | ||
44 | X509_NAME_add_entry_by_txt(name, "ST", MBSTRING_ASC, | ||
45 | "BaWue", -1, -1, 0); | ||
46 | X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, | ||
47 | "KIT", -1, -1, 0); | ||
48 | debug_print(name); | ||
49 | |||
50 | X509_NAME_add_entry_by_txt(name, "L", MBSTRING_ASC, | ||
51 | "Karlsruhe", -1, 1, 0); | ||
52 | debug_print(name); | ||
53 | |||
54 | X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, | ||
55 | "DE", -1, 0, 1); | ||
56 | debug_print(name); | ||
57 | |||
58 | return 0; | ||
59 | } | ||