Project

General

Profile

Bug #6703 ยป o.c

C example, but using OBJ_txt2nid() as well - vbatts (Vincent Batts), 07/06/2012 06:27 AM

 
1

    
2
#include <openssl/x509v3.h>
3
#include <openssl/ssl.h>
4

    
5
int main(int ac, char** av) {
6
	int i;
7
	int nid;
8
	int new_nid;
9

    
10
	if (ac == 1) {
11
		printf("Usage: %s 1.2.3.4.5 ...\n", av[0]);
12
		return 1;
13
	}
14

    
15
	for (i=1;i<ac;i++) {
16
		new_nid = OBJ_create(av[i], "NewOID", "New Object Identifier");
17
		printf("created: %d\n", new_nid);
18

    
19
		nid = OBJ_txt2nid(av[i]);
20
		if (!nid) nid = OBJ_ln2nid("New Object Identifier");
21
		if (!nid) nid = OBJ_sn2nid("NewOID");
22
		if (nid)
23
		{
24
			printf("%d %s\n", nid, av[i]);
25
		} else {
26
			printf("%s did not find anything\n", av[i]);
27
		}
28
	}
29

    
30
	return 0;
31
}
32