Let's Encrypt Certificate Request on CentOS 5 fails

On two servers I get this error

File "/usr/libexec/webmin/webmin/acme_tiny.py", line 31
    pub_exp = "0{0}".format(pub_exp) if len(pub_exp) % 2 else pub_exp
                                      ^
SyntaxError: invalid syntax
Status: 
Closed (fixed)

Comments

Which Python version do you have installed on that system? You can check by running rpm -q python

Joe's picture
Submitted by Joe on Mon, 03/21/2016 - 04:31 Pro Licensee

EPEL has newer Python versions available, if a newer version is needed. Jamie, do you know what the minimum Python version we need for the new client is?

I have python 2.4.3-56.el5 It is possible to install 2.6.8 alongside. Replacing the old version would break yum as I understand.

I have 2.6.8 installed but when working with the letsencrypt script it doesn't follow a symlink to the newer python.

You need version 2.6 installed, and make sure that the python command that appears first in Webmin's search path (set at Webmin Configuration -> Operating System and Environment).

How would you recommend to install python 2.6 alongside? I did a quick yum --enablerepo=epel search python26-devel and saw that packages for 2.6 are available

================================= Matched: python26-devel ==================================
python26-devel.i386 : The libraries and header files needed for Python development
python26-devel.x86_64 : The libraries and header files needed for Python development

But I don't want to break python 2.4 for yum and other system components on centos5

Is it safe to use the epel repo or would you recommend something else?

We unfortunately haven't done much testing with CentOS 5 and alternate repositories. I'm not sure what impact it would make to install python26 on there.

However, EPEL is usually very good at not breaking things.

Do you happen to have a test server available, running CentOS 5? If so, you may want to try installing it there first though, just to make sure you don't see any problems afterwards.

I tried several things to resolve this on CentOS 5, but finally had to resort to some script editing. No matter what I did, I could not get Virtualmin to run acme_tiny.py with the EPEL version of Python 2.6 that is installed in /usr/bin/python26. You also need the python26-argparse module.

Finally I did some grepping and edited the file /usr/libexec/webmin/webmin/letsencrypt-lib.pl on line 118. I changed this:

    my $out = &backquote_logged(
            "$python $module_root_directory/acme_tiny.py ".

To this:

    my $out = &backquote_logged(
            "$python26 $module_root_directory/acme_tiny.py ".

That actually worked (appended 26 to $python instead of reading it as $python26) and I was able to move on with my life! I hope this helps someone else :)

(edit: I wrote up a step-by-step on my blog here: https://www.tidbitsfortechs.com/2016/04/virtualmin-letsencrypt-module-centos-5-broken-quick-easy-fix/ )

Thanks for the suggestion - the next Webmin release will fix this by preferring the command python27 or python2.7 if installed, over the default python command.

Can you confirm that it also worked properly for you with Python 2.6?

Hi Jamie,

Yes, it worked fine with 2.6. The module did its job and I was able to install the resulting certificate without issue. As far as I know, there is no Python 2.7 for CentOS 5- so support for /usr/bin/python26 would be good to add in. Then again, anyone running CentOS 5 should be looking at upgrading to CentOS 7. My customer simply hasn't done it yet, so we have to make do :)

Ok, the next Webmin release will use the python26 or python2.6 command if installed, before falling back to the python command.

Status: Active » Fixed

It is working fine on CentOS Linux 5.11, Webmin 1.801, Virtualmin 5.03 Pro with python26 installed as suggested by geocrasher. Thank's a lot guys!