Blob
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"9 void10 usage(void)11 {12 fprint(2, "usage: aux/rsa2csr 'C=US ...CN=xxx' [key]");13 exits("usage");14 }16 void17 main(int argc, char **argv)18 {19 int len;20 uchar *cert;21 RSApriv *key;23 fmtinstall('B', mpfmt);24 fmtinstall('H', encodefmt);26 ARGBEGIN{27 default:28 usage();29 }ARGEND31 if(argc != 1 && argc != 2)32 usage();34 if((key = getkey(argc-1, argv+1, 1, nil)) == nil)35 sysfatal("%r");37 cert = X509req(key, argv[0], &len);38 if(cert == nil)39 sysfatal("X509req: %r");41 write(1, cert, len);42 exits(0);43 }