~ubuntu-branches/ubuntu/lucid/ssl-cert/lucid

« back to all changes in this revision

Viewing changes to make-ssl-cert

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2008-06-05 19:15:47 UTC
  • Revision ID: james.westby@ubuntu.com-20080605191547-n7p12a50280k0n8b
Tags: 1.0.19ubuntu1
* Merge from debian unstable, remaining changes:
  - replace known vulnerable weak keys and certificates caused by
    Debian openssl bug (CVE-2008-0166).
    - debian/control: Depends on openssl (0.9.8g-4ubuntu3.1),
      openssl-blacklist.
    - debian/templates: add critical debconf note.
    - debian/postinst: regenerate snakeoil key and certificate on upgrade if
      vulnerable.
  - debian/control:
    - Update Maintainer field and VCS-* fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
ask_via_debconf() {
10
10
    db_settitle make-ssl-cert/title
11
11
 
12
 
    templates="countryname statename localityname organisationname ouname hostname email"
13
 
 
14
 
    for i in $templates; do
15
 
        RET=""
16
 
        while [ "x$RET" = "x" ]; do
17
 
            db_fset make-ssl-cert/$i seen false
18
 
            db_input high make-ssl-cert/$i || true
19
 
            db_go
20
 
            db_get make-ssl-cert/$i
21
 
        done
22
 
     done
23
 
 
24
 
     db_get make-ssl-cert/countryname
25
 
     CountryName="$RET"
26
 
     db_fset make-ssl-cert/countryname seen false
27
 
 
28
 
     db_get make-ssl-cert/statename
29
 
     StateName="$RET"
30
 
     db_fset make-ssl-cert/statename seen false
31
 
 
32
 
     db_get make-ssl-cert/localityname
33
 
     LocalityName="$RET"
34
 
     db_fset make-ssl-cert/localityname seen false
35
 
 
36
 
     db_get make-ssl-cert/organisationname
37
 
     OrganisationName="$RET"
38
 
     db_fset make-ssl-cert/organisationname seen false
39
 
 
40
 
     db_get make-ssl-cert/ouname
41
 
     OUName="$RET"
42
 
     db_fset make-ssl-cert/ouname seen false
43
 
 
44
 
     db_get make-ssl-cert/hostname
45
 
     HostName="$RET"
46
 
     db_fset make-ssl-cert/hostname seen false
47
 
 
48
 
     db_get make-ssl-cert/email
49
 
     Email="$RET"
50
 
     db_fset make-ssl-cert/email seen false
 
12
    RET=""
 
13
    while [ "x$RET" = "x" ]; do
 
14
        db_fset make-ssl-cert/hostname seen false
 
15
        db_input high make-ssl-cert/hostname || true
 
16
        db_go
 
17
        db_get make-ssl-cert/hostname
 
18
    done
 
19
    
 
20
    db_get make-ssl-cert/hostname
 
21
    HostName="$RET"
 
22
    db_fset make-ssl-cert/hostname seen false
51
23
}
52
24
 
53
25
make_snakeoil() {
54
 
     CountryName="XX"
55
 
     StateName="There is no such thing outside US"
56
 
     LocalityName="Everywhere"
57
 
     OrganisationName="OCOSA"
58
 
     OUName="Office for Complication of Otherwise Simple Affairs"
59
 
     HostName="$(hostname -f || hostname)"
60
 
     Email="root@$HostName"
 
26
    if ! HostName="$(hostname -f)" ; then
 
27
        HostName="$(hostname)"
 
28
        echo make-ssl-cert: Could not get FQDN, using \"$HostName\".
 
29
        echo make-ssl-cert: You may want to fix your /etc/hosts and/or DNS setup and run
 
30
        echo make-ssl-cert: 'make-ssl-cert generate-default-snakeoil --force-overwrite'
 
31
        echo make-ssl-cert: again.
 
32
    fi
61
33
}
62
34
 
63
35
create_temporary_cnf() {
64
 
    sed -e s#@CountryName@#"$CountryName"# \
65
 
        -e s#@StateName@#"$StateName"# \
66
 
        -e s#@LocalityName@#"$LocalityName"# \
67
 
        -e s#@OrganisationName@#"$OrganisationName"# \
68
 
        -e s#@OUName@#"$OUName"# \
69
 
        -e s#@HostName@#"$HostName"# \
70
 
        -e s#@Email@#"$Email"# \
71
 
        $template > $TMPFILE
 
36
    sed -e s#@HostName@#"$HostName"# $template > $TMPFILE
72
37
}
73
38
 
74
39
# Takes two arguments, the base layout and the output cert.
112
77
 
113
78
# create the certiface.
114
79
 
115
 
export RANDFILE=/dev/random
116
 
 
117
80
if [ "$1" != "generate-default-snakeoil" ]; then
118
 
    openssl req -config $TMPFILE -new -x509 -nodes -out $output -keyout $output > /dev/null 2>&1
 
81
    openssl req -config $TMPFILE -new -x509 -days 3650 -nodes -out $output -keyout $output > /dev/null 2>&1
119
82
    chmod 600 $output
120
83
    # hash symlink
121
84
    cd $(dirname $output)
122
 
    ln -sf $(basename $output) $(openssl x509 -hash -noout -in $output)
 
85
    ln -sf $(basename $output) $(openssl x509 -hash -noout -in $(basename $output))
123
86
else
124
 
    openssl req -config $TMPFILE -new -x509 -nodes \
 
87
    openssl req -config $TMPFILE -new -x509 -days 3650 -nodes \
125
88
        -out /etc/ssl/certs/ssl-cert-snakeoil.pem \
126
89
        -keyout /etc/ssl/private/ssl-cert-snakeoil.key > /dev/null 2>&1
127
90
    chmod 644 /etc/ssl/certs/ssl-cert-snakeoil.pem