2
/* Copyright (C) 2000-2005 Thomas Bopp, Thorsten Hampel, Ludger Merkens
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* $Id: create_cert.pike.in,v 1.1.1.1 2006/03/27 12:40:19 exodusd Exp $
21
constant cvs_version="$Id: create_cert.pike.in,v 1.1.1.1 2006/03/27 12:40:19 exodusd Exp $";
23
import Standards.ASN1.Types;
26
#if !constant(PrintableString)
27
class PrintableString {
28
inherit asn1_printable_string;
32
void main(int argc, array argv)
34
function random = Crypto.randomness.reasonably_random()->read;
35
object rsa = Crypto.rsa()->generate_key(512, random);
37
string fname = "steam.cer";
39
for ( j = 1; j < argc; j++ ) {
40
if ( sscanf(argv[j], "--file=%s", fname) == 0 )
45
string hname = gethostname();
47
({ ([ "countryName": PrintableString("Germany"),
48
"organizationName": PrintableString("Uni Paderborn"),
49
"organizationUnitName": PrintableString("sTeam"),
50
"localityName": PrintableString("Paderborn"),
51
"stateOrProvinceName":PrintableString("NRW"),
52
"commonName": PrintableString(hname), ]),
55
for ( int i = j; i < argc; i++ ) {
57
({ ([ "countryName": PrintableString("Germany"),
58
"organizationName": PrintableString("Uni Paderborn"),
59
"organizationUnitName": PrintableString("sTeam"),
60
"localityName": PrintableString("Paderborn"),
61
"stateOrProvinceName":PrintableString("NRW"),
62
"commonName": PrintableString(argv[i]), ]),
65
string cert = Tools.X509.make_selfsigned_rsa_certificate(
66
rsa, 60*60*24*1000, attr);
67
string der = MIME.encode_base64(cert);
68
string rsa_str = MIME.encode_base64(Standards.PKCS.RSA.private_key(rsa));
70
der = "-----BEGIN CERTIFICATE-----\n"+der+
71
"\n-----END CERTIFICATE-----\n";
72
Stdio.write_file(fname, der+
73
"\n-----BEGIN RSA PRIVATE KEY-----\n"+
74
rsa_str+"\n-----END RSA PRIVATE KEY\n");