~ubuntu-branches/ubuntu/wily/steam/wily

« back to all changes in this revision

Viewing changes to tools/create_cert.pike.in

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-10-29 19:51:18 UTC
  • mfrom: (1.1.4) (0.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029195118-b9bxciz5hwx5z459
Tags: 1:1.0.0.39-2ubuntu1
Add an epoch to the version number as there was an unrelated steam package
in the archive with a higher version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!@PIKE@
2
 
/* Copyright (C) 2000-2005  Thomas Bopp, Thorsten Hampel, Ludger Merkens
3
 
 *
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.
8
 
 *
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.
13
 
 *
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
17
 
 * 
18
 
 * $Id: create_cert.pike.in,v 1.1.1.1 2006/03/27 12:40:19 exodusd Exp $
19
 
 */
20
 
 
21
 
constant cvs_version="$Id: create_cert.pike.in,v 1.1.1.1 2006/03/27 12:40:19 exodusd Exp $";
22
 
 
23
 
import Standards.ASN1.Types;
24
 
 
25
 
 
26
 
#if !constant(PrintableString) 
27
 
class PrintableString {
28
 
    inherit asn1_printable_string;
29
 
}
30
 
#endif
31
 
 
32
 
void main(int argc, array argv)
33
 
{
34
 
    function random = Crypto.randomness.reasonably_random()->read;
35
 
    object rsa = Crypto.rsa()->generate_key(512, random);
36
 
    array attr = ({ });
37
 
    string fname = "steam.cer";
38
 
    int j;
39
 
    for ( j = 1; j < argc; j++ ) {
40
 
      if ( sscanf(argv[j], "--file=%s", fname) == 0 )
41
 
        break;
42
 
    }
43
 
 
44
 
    if ( j == argc ) {
45
 
      string hname = gethostname();
46
 
        attr += 
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), ]),
53
 
        });
54
 
    }
55
 
    for ( int i = j; i < argc; i++ ) {
56
 
      attr += 
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]), ]),
63
 
               });
64
 
    }           
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));
69
 
    
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");
75
 
}