Hi Conrad,
Thank you for your reply. Yes, the OpenSSL v1.0.2 in the ubuntu should solve this problem.
I downloaded and built the OpenSSL v1.1.0f libraries in my home directory, and downloaded python 3.5.3 source and compiled it with this OpenSSL 1.1.0. Then when executing my python script at the python anywhere console command line the Apple push notification now work using this updated OpenSSL.
But, I'm sure if I can use this compiled python to serve pages on PythonAnywhere?
I used the commands below in case anyone else whats to do similar in future. There's probably a better or shorter way to do this.
(1) Build the OpenSSL libraries:
( Based on: https://github.com/magnumripper/JohnTheRipper/wiki/Howto-build-non-root-when-system-does-not-have-OpenSSL. )
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
tar zxf openssl-1.1.0f.tar.gz
cd openssl-1.1.0f
mkdir ~/ssl
./Configure --prefix=$HOME/ssl linux-x86_64 # if your system is not linux-x86_64, you will have to pick the right one
make -build_libs > mymake.log # or gmake, or whatever 'make' tool is on your system
make -s test
make install_sw # I like installing without using -s to 'see' what is done
(2) Set paths to the new libraries in my ~./bashrc:
OPENSSL_CFLAGS="-I$HOME/ssl -I$HOME/ssl/include"
OPENSSL_LIBS="-L$HOME/ssl/lib"
export CFLAGS=$OPENSSL_CFLAGS
export CPPFLAGS=$OPENSSL_CFLAGS
export LDFLAGS=$OPENSSL_LIBS
export LD_LIBRARY_PATH=$HOME/ssl/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=$HOME/ssl/lib:$LIBRARY_PATH
source ~/.bashrc
(3) Build Python with these new local OpenSSL libraries:
( Based on older version: http://thelazylog.com/install-python-as-local-user-on-linux/
and: https://stackoverflow.com/questions/38697181/compiling-python-2-7-12-with-non-system-openssl-on-centos-5 )
wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz
tar zxf Python-3.5.3.tgz
cd Python-3.5.3
mkdir ~/python35
configure --prefix=$HOME/python35
make && make install
export PATH=$HOME/python35/bin:$PATH
(4) Check this python is using this latest OpenSSL
python3
import ssl
ssl.OPENSSL_VERSION
'OpenSSL 1.1.0f 25 May 2017'
exit()
(5) Install modules
pip3 install --global-option=build_ext --global-option="-I$HOME/ssl/include" --global-option="-L$HOME/ssl/lib" gobiko.apns
and other modules...
(6) Check thes modules are also using this latest OpenSSL
python -m OpenSSL.debug
(7) Create virtualenv, and set PythonAnywhere to use this python35
I'm not sure if it is possible to use this compiled python3.5 within the PythonAnywhere server. I tried making an virtualenv, and setting the web interface to use this:
pip3 install virtualenv virtualenvwrapper
mkvirtualenv --python=/home/sbridgett/python35/bin/python sm17_ssl_110
pip3 install -U --global-option=build_ext --global-option="-I/home/sbridgett/ssl/include" --global-option="-L/home/sbridgett/ssl/lib" gobiko.apns
pip3 install django
but get errors in the server log about:
initialized 50 metrics
2017-07-21 16:04:32 Traceback (most recent call last):
2017-07-21 16:04:32 File "/bin/user_wsgi_wrapper.py", line 30, in <module>
2017-07-21 16:04:32 import logging
2017-07-21 16:04:32 File "/home/sbridgett/python35/lib/python3.5/logging/init.py", line 26, in <module>
2017-07-21 16:04:32 import sys, os, time, io, traceback, warnings, weakref, collections
2017-07-21 16:04:32 File "/home/sbridgett/python35/lib/python3.5/traceback.py", line 5, in <module>
2017-07-21 16:04:32 import linecache
2017-07-21 16:04:32 File "/home/sbridgett/.virtualenvs/sm17_ssl_110/lib/python3.5/linecache.py", line 8, in <module>
2017-07-21 16:04:32 import functools
2017-07-21 16:04:32 File "/home/sbridgett/.virtualenvs/sm17_ssl_110/lib/python3.5/functools.py", line 23, in <module>
2017-07-21 16:04:32 from weakref import WeakKeyDictionary
2017-07-21 16:04:32 File "/home/sbridgett/.virtualenvs/sm17_ssl_110/lib/python3.5/weakref.py", line 12, in <module>
2017-07-21 16:04:32 from _weakref import (
2017-07-21 16:04:32 ImportError: cannot import name '_remove_dead_weakref'
2017-07-21 16:04:32 unable to load app 0 (mountpoint='') (callable not found or import error)
2017-07-21 16:04:32 *** no app loaded. going in full dynamic mode ***
2017-07-21 16:04:32 *** uWSGI is running in multiple interpreter mode ***
2017-07-21 16:04:32 gracefully (RE)spawned uWSGI master process (pid: 14323)
2017-07-21 16:04:32 spawned uWSGI worker 1 (pid: 14324, cores: 1)