Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
#include <bio.h>
4
#include <auth.h>
5
#include <mp.h>
6
#include <libsec.h>
7
#include "rsa2any.h"
8
 
9
void
10
usage(void)
11
{
12
	fprint(2, "usage: auth/rsa2x509 [-e expireseconds] 'C=US ...CN=xxx' [key]");
13
	exits("usage");
14
}
15
 
16
void
17
main(int argc, char **argv)
18
{
19
	int len;
20
	uchar *cert;
21
	ulong valid[2];
22
	RSApriv *key;
23
 
24
	fmtinstall('B', mpfmt);
25
	fmtinstall('H', encodefmt);
26
 
27
	valid[0] = time(0);
28
	valid[1] = valid[0] + 3*366*24*60*60;
29
 
30
	ARGBEGIN{
31
	default:
32
		usage();
33
	case 'e':
34
		valid[1] = valid[0] + strtoul(ARGF(), 0, 10);
35
		break;
36
	}ARGEND
37
 
38
	if(argc != 1 && argc != 2)
39
		usage();
40
 
41
	if((key = getkey(argc-1, argv+1, 1, nil)) == nil)
42
		sysfatal("%r");
43
 
44
	cert = X509gen(key, argv[0], valid, &len);
45
	if(cert == nil)
46
		sysfatal("X509gen: %r");
47
 
48
	write(1, cert, len);
49
	exits(0);
50
}