Merge ~bryce/ubuntu/+source/ssl-cert:ssl-cert-sru-lp1853021-hirsute into ubuntu/+source/ssl-cert:ubuntu/devel

Proposed by Bryce Harrington
Status: Merged
Approved by: Bryce Harrington
Approved revision: 89e28e390817c31ac0fce1c485648805be5a319c
Merge reported by: Bryce Harrington
Merged at revision: 89e28e390817c31ac0fce1c485648805be5a319c
Proposed branch: ~bryce/ubuntu/+source/ssl-cert:ssl-cert-sru-lp1853021-hirsute
Merge into: ubuntu/+source/ssl-cert:ubuntu/devel
Diff against target: 161 lines (+71/-21)
3 files modified
debian/changelog (+10/-0)
debian/control (+4/-3)
make-ssl-cert (+57/-18)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Paride Legovini (community) Needs Information
Canonical Server Pending
git-ubuntu developers Pending
Review via email: mp+393784@code.launchpad.net

Description of the change

Fix for server-next bug regarding a missing capability in make-ssl-cert to specify the expiration length of a self-signed certificate.

Essentially this simply needed a way to pass in a value for the -days option for openssl, however the script lacked provisions for conveniently adding new options. Instead of hacking in the new option, I've implemented a general option handling capability that should make the script more maintainable into the future.

While not mentioned in the original bug report, I expect the desire is to see this command line support also SRU'd to past releases. This may be too invasive a change with too narrow a use case to warrant SRU, so at least for now I'm targeting it to hirsute only. However, I've gone ahead and filled in the SRU template anyway. So, if the fix proves worthy and desirable, it should be straightforward to backport.

PPA: https://launchpad.net/~bryce/+archive/ubuntu/ssl-cert-sru-lp1853021/+packages
Bug: https://bugs.launchpad.net/ubuntu/+source/ssl-cert/+bug/1853021

To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The PPA seems not to carry the new version?
root@h:~# vim /usr/sbin/make-ssl-cert
root@h:~# /usr/sbin/make-ssl-cert -h
Usage: /usr/sbin/make-ssl-cert template output [--force-overwrite]
Usage: /usr/sbin/make-ssl-cert generate-default-snakeoil [--force-overwrite]

review: Needs Fixing
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I like adding proper arg handling, but IMHO this is one of the cases were we will end up with a lot of pain doing it as Ubuntu delta.

How about - after gettign it reviewed and tested here - filing it against https://bugs.debian.org/cgi-bin/pkgreport.cgi?repeatmerged=no&src=ssl-cert and proposing it against https://salsa.debian.org/apache-team/ssl-cert which is the salsa repo.

P.S. might be also worth to mention salsa in d/control

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Some more inline comments added

Also this has whitespace damage in line 40 (the original has that, but you could fix it in your proposal)

   39 done
   40 ····
   41 db_get make-ssl-cert/hostname

There are more - worth to clean up and unify when proposing to Debian IMHO.

In general some shellcheck treatment could raise the quality while we are at it.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

BTW - my reasoning for proposing this to Debian once cleaned - Plenty of other things packages but also guides/howtos on the net use this command. Going together with changed options will ensure they are usable as-is on both sides.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

The parsing right now is very bash'y e.g.

--expiration-days=5 OK

--expiration-days 5 FAILS
  Unrecognized option --expiration-days

--expiration-days= 5
 opt_expiration_days=
 template=5

Package: util-linux
Essential: yes
and has /usr/bin/getopt, so should we just use that to improve on it (up for discussion)

d2000a1... by Bryce Harrington

d/control: Update git links to salsa

Revision history for this message
Bryce Harrington (bryce) wrote :

PPA is updated at https://launchpad.net/~bryce/+archive/ubuntu/ssl-cert-sru-lp1853021-snakeoil now

> I like adding proper arg handling, but IMHO this is one of the cases were we will end up with a lot of pain doing it as Ubuntu delta.

Completely agreed, same thought occurred to me, and yes I do keep a TODO to forward to Debian once the MP is acceptable.

> P.S. might be also worth to mention salsa in d/control

Good idea, the existing links are obsolete. I've updated them.

> The parsing right now is very bash'y e.g.
> --expiration-days=5 OK
> --expiration-days 5 FAILS
> Unrecognized option --expiration-days

I know, and I'm not happy about this as I strongly prefer the latter getopts-style format personally. However, I thought adding getopts might be a bridge too far for this package. I figure this was a less invasive change, but would be more than happy to move to getopts if Debian is ok with it. If you feel strongly that getopts *should* be used I'll update to use that.

Regarding shellcheck, yes I noticed there are numerous issues as well. I opted, however, to only fix shellcheck issues involved with the exact code lines I changed, to keep the patch minimal. I noticed the whitespace was handled irregularly elsewhere in the script so didn't worry about that, but I'll go and make sure all my touched lines are consistently using spaces instead of tabs. Followup patches to address both shellcheck and whitespace may make sense to consider doing when upstreaming the patch to Debian.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

> If you feel strongly that getopts *should* be used I'll update to use that.

I'd personally prefer, but my opinions are not strong enough to
force/convince you.
Since we go through Debian it depends on their preference more than on mine.

> ... upstreaming the patch to Debian.

Thanks, that is the right way. If they are slow or denying even if we
are kind and responsive we can still think about adding it as delta
then.

Revision history for this message
Paride Legovini (paride) wrote :

Should we also lower the default validity of the certificate to something like 800 days as part of this change? This would address the specific issue raised by LP: #1853021, and I think it makes sense to have defaults that produce certificates that are compatible with browsers.

(Should we *only* lower the cert validity if Debian is slow/unresponsive, instead of adding --expiration-days in a delta? The risk I see is Debian implementing the same in a different way, and ending up with two different interfaces that are difficult to reconcile and that could require even more deltas in other packages.)

review: Needs Information
Revision history for this message
Bryce Harrington (bryce) wrote :

@Paride given the new standard is 825 days, I also wondered if that might be a more sensible value to set as the default. One drawback is that doing so would certainly be a behavioral change, and may make the changes non-SRU-able. But going forward that might be a good change; another thing to discuss with Debian I suppose.

Regardless, I do think that adding --expiration-days is worthwhile. From the referenced links, I see there was a lot of debate, with some CA's preferring longer expiration times, and others shorter. So I think from the distro POV having this as a settable option gives our users flexibility that they need.

@Christian, one of the considerations I made with skipping getopts is that getopts only handles single-letter options, but this script's one parameter is a long option. The other usage mode of permitting "<template> <output>" arguments also needs a bit of special handling to use cleanly with getopts. It ends up being a number of lines for argument parsing to handle just a couple options.

I notice this is not marked Approved yet; do I interpret this correctly to mean you prefer this work be done only in Debian rather than Ubuntu, or are you ok with the branch as-is to land as temporary delta for Ubuntu while we wait on Debian?

Revision history for this message
Bryce Harrington (bryce) wrote :

I've gathered the review feedback for suggested changes to forward to debian into this branch:

https://code.launchpad.net/~bryce/ubuntu/+source/ssl-cert/+git/ssl-cert/+ref/ssl-cert-sru-lp1853021-debian

I split up the diff into discrete changes, ordered in (I think) likelihood of their acceptance. This includes fixing whitespace and shellcheck issues (except one) as Christian suggested. I changed the default expiration period to 825 as Paride suggested. I finished with a conversion to using getopts, although as mentioned above I think it gets a bit too much for this script; I left it as the final patch so if Debian doesn't care for it, it can be popped off the stack easy.

Please look this over and +1 or give any other feedback before I send off to Debian.

Also, I'd appreciate clarification if I should proceed with landing the Ubuntu MP as (temporary) delta, or wait until this is taken by Debian.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Thanks for wrapping all that up Bryce.
I'm +1 on the current content and state of the discussion.

For the uploads I'm strongly voting for "try to convince Debian first". I mentioned it and also Paride nicely put it as "ending up with two different interfaces that are difficult to reconcile and that could require even more deltas in other package".

I'd only consider an Ubuntu only upload for this if Debian really fails to participate in the discussion at all.
Both Distributions have feature freezes early on in 2021 so proposing and pushing for this change now is the right time.

In terms of SRUability e.g. of the default time - I'd not bother about that now. Let us make 21.04 great (as proposed) and later decide on the SRUs if we can include those changes or not (I assume we can't).

review: Approve
Revision history for this message
Bryce Harrington (bryce) wrote :

Thanks for the clarification. I've proposed a MP to debian here:

https://salsa.debian.org/apache-team/ssl-cert/-/merge_requests/2

Revision history for this message
Bryce Harrington (bryce) wrote :

Debian accepted the changes discussed above, and we've sync'd the same in via the new 1.1.0. The changes not taken (e.g. altering the default validity time) are technically not strictly necessary for resolving the original bug report so I don't think that needs followed up on.

Per Christian's last comment above will hold on SRUing until there is a specific request for it, and decide at that time.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 01fad6a..6d51bd9 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+ssl-cert (1.0.39ubuntu1) hirsute; urgency=medium
7+
8+ * make-ssl-cert: Add a --expiration-days parameter
9+ (LP: #1853021)
10+ - This parameter enables users to customize the expiration of self-signed
11+ certificates.
12+ * d/control: Update git links to salsa
13+
14+ -- Bryce Harrington <bryce@canonical.com> Fri, 13 Nov 2020 00:39:17 +0000
15+
16 ssl-cert (1.0.39) unstable; urgency=medium
17
18 * Always put the common name also in the SubjectAltName. This is required
19diff --git a/debian/control b/debian/control
20index 324d965..f958433 100644
21--- a/debian/control
22+++ b/debian/control
23@@ -1,12 +1,13 @@
24 Source: ssl-cert
25 Section: utils
26 Priority: optional
27-Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
28+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
29+XSBC-Original-Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
30 Uploaders: Tollef Fog Heen <tfheen@debian.org>, Stefan Fritsch <sf@debian.org>
31 Build-Depends: debhelper (>= 7), po-debconf
32 Standards-Version: 3.9.8
33-Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-apache/ssl-cert.git
34-Vcs-Git: git://anonscm.debian.org/pkg-apache/ssl-cert.git
35+Vcs-Git: https://salsa.debian.org/apache-team/ssl-cert.git
36+Vcs-Browser: https://salsa.debian.org/apache-team/ssl-cert
37
38 Package: ssl-cert
39 Architecture: all
40diff --git a/make-ssl-cert b/make-ssl-cert
41index 152e9f9..ded374a 100755
42--- a/make-ssl-cert
43+++ b/make-ssl-cert
44@@ -6,6 +6,20 @@
45 db_version 2.0
46 db_capb backup
47
48+progname=$(basename "${0}")
49+
50+usage() {
51+ cat >&2 <<EOF
52+Usage: ${progname} [options] <template> <output>
53+ ${progname} [options] generate-default-snakeoil
54+
55+Options:
56+ --force-overwrite
57+ --expiration-days=<days>
58+EOF
59+ exit "${1}"
60+}
61+
62 ask_via_debconf() {
63 RET=""
64 if db_settitle make-ssl-cert/title ; then
65@@ -56,35 +70,60 @@ create_temporary_cnf() {
66 sed -e s#@HostName@#"$HostName"# -e s#@SubjectAltName@#"$SubjectAltName"# $template > $TMPFILE
67 }
68
69-# Takes two arguments, the base layout and the output cert.
70-
71-if [ $# -lt 2 ] && [ "$1" != "generate-default-snakeoil" ]; then
72- printf "Usage: $0 template output [--force-overwrite]\n";
73- printf "Usage: $0 generate-default-snakeoil [--force-overwrite]\n";
74- exit 1;
75-fi
76+# Process arguments
77+subcommand=
78+opt_force_overwrite="false"
79+opt_expiration_days="3650"
80+for arg in "${@}"; do
81+ case "${arg}" in
82+ --help | -h | \?)
83+ usage 0
84+ ;;
85+ --force-overwrite)
86+ opt_force_overwrite="true"
87+ ;;
88+ --expiration-days=*)
89+ opt_expiration_days="${arg#*=}"
90+ ;;
91+ generate-default-snakeoil)
92+ subcommand="generate-default-snakeoil"
93+ ;;
94+ --*)
95+ printf "Unrecognized option ${arg}\n\n"
96+ usage 1
97+ ;;
98+ *)
99+ subcommand="manual"
100+ template="${arg}"
101+ ;;
102+ esac
103+ shift
104+done
105+
106+if [ "${subcommand}" = "manual" ]; then
107+ output="${1}"
108+ [ -n "${output}" ] || usage 1
109
110-if [ "$1" != "generate-default-snakeoil" ]; then
111- template="$1"
112- output="$2"
113 # be anal in manual mode.
114 if [ ! -f $template ]; then
115 printf "Could not open template file: $template!\n";
116 exit 1;
117 fi
118- if [ -f $output ] && [ "$3" != "--force-overwrite" ]; then
119+ if [ -f $output ] && [ "${opt_force_overwrite}" != "true" ]; then
120 printf "$output file already exists!\n";
121 exit 1;
122 fi
123 ask_via_debconf
124-else
125+elif [ "${subcommand}" = "generate-default-snakeoil" ]; then
126 template="/usr/share/ssl-cert/ssleay.cnf"
127 if [ -f "/etc/ssl/certs/ssl-cert-snakeoil.pem" ] && [ -f "/etc/ssl/private/ssl-cert-snakeoil.key" ]; then
128- if [ "$2" != "--force-overwrite" ]; then
129- exit 0
130+ if [ "${opt_force_overwrite}" != "true" ]; then
131+ exit 0
132 fi
133 fi
134 make_snakeoil
135+else
136+ usage 1
137 fi
138
139 # # should be a less common char
140@@ -102,8 +141,8 @@ create_temporary_cnf
141
142 umask 077
143
144-if [ "$1" != "generate-default-snakeoil" ]; then
145- if ! openssl req -config $TMPFILE -new -x509 -days 3650 -nodes -sha256 \
146+if [ "${subcommand}" = "manual" ]; then
147+ if ! openssl req -config $TMPFILE -new -x509 -days ${opt_expiration_days} -nodes -sha256 \
148 -out $output -keyout $output > $TMPOUT 2>&1
149 then
150 echo Could not create certificate. Openssl output was: >&2
151@@ -114,8 +153,8 @@ if [ "$1" != "generate-default-snakeoil" ]; then
152 # hash symlink
153 cd $(dirname $output)
154 ln -sf $(basename $output) $(openssl x509 -hash -noout -in $(basename $output))
155-else
156- if ! openssl req -config $TMPFILE -new -x509 -days 3650 -nodes -sha256 \
157+elif [ "${subcommand}" = "generate-default-snakeoil" ]; then
158+ if ! openssl req -config $TMPFILE -new -x509 -days ${opt_expiration_days} -nodes -sha256 \
159 -out /etc/ssl/certs/ssl-cert-snakeoil.pem \
160 -keyout /etc/ssl/private/ssl-cert-snakeoil.key > $TMPOUT 2>&1
161 then

Subscribers

People subscribed via source and target branches