Stunnel no longer works after upgrading to Yosemite - django

I've been using stunnel for local Django development on SSL-enabled pages for a while, but since upgrading to Yosemite it seems to have stopped working:
$ sudo stunnel stunnel/dev_https
dyld: Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
Referenced from: /usr/bin/stunnel
Reason: image not found
I tried building libssl from source using this gist and symlinking libssl.1.0.0.dylib to /opt/local/lib/libssl.1.0.0.dylib. That then failed, looking for /opt/local/lib/libcrypto.1.0.0.dylib. So I symlinked the version I'd just built to that expected path, and got this:
$ sudo stunnel stunnel/dev_https
dyld: Library not loaded: /usr/local/ssl/lib/libcrypto.1.0.0.dylib
Referenced from: /opt/local/lib/libssl.1.0.0.dylib
Reason: image not found
What's going on here? stunnel is at /usr/bin/stunnel and I've checked it's not installed via homebrew. Has anyone else managed to work this out?

I just got stunnel working for Django on Yosemite. If I remember correctly, I also had to previously fix my libssl as explained in this other answer for psycopg2.
Then, I use homebrew for everything:
$ brew install stunnel
$ openssl req -new -x509 -days 9999 -nodes -out stunnel.pem -keyout stunnel.pem
I put this in stunnel.conf (derived from here):
pid=/tmp/stunnel.pid
setuid=nobody
setgid=nobody
foreground=yes
client=no
[https]
cert = ./stunnel.pem
accept=443
connect=5000
I run stunnel with:
$ sudo stunnel stunnel.conf
And run Django with:
$ python manage.py runserver 0.0.0.0:5000
Hope that helps.

Related

Can't call Stripe on Appengine development server even with latest ssl

I am running into the same issue on my development server. I have already checked out stackoverflow.com/questions/46799365/… and that hasn't worked for me.
python -V
Python 2.7.11
and as soon as I call stripe, I get the Support for test mode requests made with versions of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
My app.yaml has ssl set to "latest" libraries: - name: django version: "1.9" - name: jinja2 version: "2.6" - name: markupsafe version: "0.15" - name: ssl version: latest - name: pycrypto version: latest
So am I supposed to do something with sandbox.py? I think my request is version 2.16.0 because I was getting some other environment issue when it wasn't. Is that he culprit or something else?
Here's the exact error
PermissionError at /
Request req_DrUOViv9FnjhAx: Support for test mode requests made with versions
of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
Request Method:
GET
Request URL:
http://localhost:8080/
Django Version:
1.9.5
Exception Type:
PermissionError
Exception Value:
Request req_DrUOViv9FnjhAx: Support for test mode requests made with versions of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
Exception Location:
lib/stripe/api_requestor.py in handle_error_response, line 178
Python Executable:
/Users/USERNAME/PycharmProjects/PROJECTNAME/virtualenv-dev/bin/python
Python Version:
2.7.11
Python Path:
['/Users/USERNAME/PycharmProjects/PROJECTNAME',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine',
'/Users/USERNAME/PycharmProjects/PROJECTNAME',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine',
'/Users/USERNAME/PycharmProjects/PROJECTNAME/virtualenv/lib/python2.7',
'/Users/USERNAME/PycharmProjects/PROJECTNAME/virtualenv/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/django-1.9',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/jinja2-2.6',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/markupsafe-0.15',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/ssl-2.7.11',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/pycrypto-2.6',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/setuptools-0.6c11',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/pytz-2017.2',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/webob-1.1.1',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/werkzeug-0.11.10',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/yaml-3.10',
'lib']
Server time:
Sat, 24 Mar 2018 00:43:28 -0500
I spent many hours on this about a month ago. It was a huge pain, but I finally got it to work.
One issue I was having is that Brew does something very annoying with its python versions. It makes python v3 the default so if you type python in the shell you get v3 and not v2. I manually changed the relevant symlinks in '/usr/local/bin' to make v2 the default.
I don't remember all the steps I took, but you'll want your '/usr/local/bin' to look something like this:
openssl -> /usr/local/Cellar/openssl/1.0.2n/bin/openssl
pip -> ../Cellar/python/2.7.14_3/bin/pip2
python -> ../Cellar/python/2.7.14_3/bin/python2
You'll then want to delete your virtualenv's and recreate them.
Note that I don't use python v3 at all, so if you need both v2 and v3 then YMMV.
In addition to using the latest GAE ssl library, when running the application on the local development server you may also need to upgrade your local system's openssl library.
From How do I upgrade my Stripe integration from TLS 1.0 to TLS 1.2? (other specific OS versions are mentioned separately):
If you are using any other system, or are already using brew on OS X, you will need to upgrade your OpenSSL version.
And from How do I upgrade my OpenSSL to support TLS 1.2? (other specific OS versions are mentioned separately):
If you are using any other Linux variant, you will need to ensure that
running openssl version gives a version of at least 1.0.1. If it
does not, you will need to take package updates, and may need to
upgrade to a newer version of your operating system.
Hope this helps someone in this situation....I had my IT admin help me and and it was a combination of things so I'm posting the solution here for my case to save someone else from the same frustration.
These instructions assume you are running these commands all as an Administrator
First remove HomeBrew:
echo -ne 'y\n' | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
sudo rm -rf /usr/local/Homebrew
sudo rm -rf /usr/local/Caskroom
sudo rm -rf /usr/local/Cellar
Remove other Pythons installed (v2)
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
sudo rm -rf "/Applications/Python 2.7"
Check for links and remove any you find with Cellar in the path
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | grep 'Cellar'
unlink <## Remove those you found ##>
Re-install Homebrew
echo -ne 'y\n' | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Add in openssl
brew install openssl
brew postinstall openssl
brew link openssl --force
Force Link openssl if needed
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
Add in Python
brew install python#2
brew postinstall python#2
brew link python#2 --force
link openssl and Python (ensure these versions are what you have installed)
ln -s /usr/local/Cellar/openssl/1.0.2o/bin/openssl /usr/local/bin/openssl
ln -s /usr/local/Cellar/openssl/1.0.2o/bin/openssl /usr/local/ssl/bin/openssl
ln -s /usr/local/Cellar/python/2.7.14/bin/python /usr/local/bin/python
Clean HomeBrew Once Installed
brew cleanup -s
brew cask cleanup
brew prune
From here the command showed the correct version
python -c 'import ssl; print ssl.OPENSSL_VERSION'

rbenv install not downloading ruby version

Installing ruby version with rbenv rbenv install -lreturns the proper list. However
$ rbenv install 2.3.4 -v
fails on the download, even though it can be downloaded via a browser. My hunch about an improper version of openssl (due to some distant memory of having such issues - tls version? - in the past) is supported in verbose mode:
ruby-build: use openssl from homebrew
/var/folders/kV/kVDOSPkcEuqSVnTjenAVRE+++TI/-Tmp-/ruby-build.20170601122915.1010 ~ Downloading ruby-2.3.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2
curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
error: failed to download ruby-2.3.4.tar.bz2
how to overcome? can I point rbenv to use the downloaded tarball?
The reason is because rbenv use old system curl and old system openssl with it, which knows nothing about protocols TLS v 1.1-1.3. For me, installing new version of curl and openssl with brew did the work:
brew install openssl#1.1
brew install curl
Then add installed curl to your PATH (before default path, which is /usr/bin), and ensure that openssl of actual brew's version is also there (add this to your ./bash_profile or ./zshrc or etc):
export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"
You can make sure after relaunch of terminal that latest versions of this programs will be used by trying
which -a openssl
which -a curl
openssl version -a
curl -V
First two commands should output all paths with the programs, but top ones should be brew versions. Last two commands should show latest versions of programs (1.1.0f and 7.55 for me now).
Now try
rbenv install [version]
Works on MacOS Sierra with enabled SIP.

Can't install virtualbox in Arch

I have tried to install Virtualbox on Arch(4.7.0-1) using pacman and everything seems to go fine until I try to run it. I get the following message
WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (4.7.0-1-ARCH) or it failed to
load. Please recompile the kernel module and install it by
sudo /sbin/vboxconfig
You will not be able to start VMs until this problem is fixed.
VirtualBox: supR3HardenedMainGetTrustedMain: dlopen("/usr/lib/virtualbox/VirtualBox.so",) failed: /usr/lib/libQt5Core.so.5: file too short
Any thoughts on where I should start looking to debug this?
Since version 5.0.16, virtualbox-host-modules-arch and virtualbox-host-dkms use systemd-modules-load.service to load all four VirtualBox modules at boot time.
To load the module manually, run: modprobe vboxdrv
https://wiki.archlinux.org/index.php/VirtualBox#Load_the_VirtualBox_kernel_modules
This answer was tested only in Ubuntu and Debian 9 in my case, but maybe can works for you.
I think the problem is that the vboxdrv module is not signed and therefore not loaded with the kernel. This will happen if your computer has the SecureBoot mode activated, something very common in modern equipment.
That's why I get this error opening any machine in the Virtual Box
Kernel driver not installed (rc=-1908)
Do the following steps to sign a driver, and it is loaded as a kernel module:
1. Install the mkutil package to be able to do signed.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mokutil
2. generate the signature file:
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
3. Then add it to the kernel:
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
4. Register it for the Secure Boot.
IMPORTANT! That will ask you for a password, put the one you want, you will only have to use it once in the next reboot.
sudo mokutil --import MOK.der
5. Finally, restart the computer. A blue screen will appear with a keyboard wait, press the key that asks you to interrupt the boot.
When you are inside the blue screen, select
Enroll MOK > Continue > Yes > and it will ask you for the password
that you have previously entered, you will enter it and you will be informed that the operation has been completed successfully.
Now your operating system will start and you can now use VirtualBox without problem :)
Hope this help someone.
Open Terminal - Verify version / codename
Code:
lsb_release -a
Using whatever plain text editors like gedit/scite/bash
Code:
sudo gedit /etc/apt/sources.list
Add the following line to your /etc/apt/sources.list:
Code:
deb http://download.virtualbox.org/virtualbox/debian xenial contrib
Save and Close
Add Key, and combine with Downloading and Registering;
Code:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
Make sure DKMS is installed. May need to re-install to current kernal.
Code:
dkms status
You might encounter an error at this point complaining about linux-headers, simply download the header package by apt-get install linux-headers-5.4.0-28-generic
Make sure Computer and OS is upto date
Code:
sudo apt-get autoclean sudo apt-get clean sudo apt-get autoremove sudo apt-get update sudo apt-get upgrade
Rebuild all DKMS modules for the currently running kernel:
Code:
dkms autoinstall
Install Latest Version of VirtualBox
Code:
sudo apt-get install virtualbox

How to check if mod_wsgi is installed on a shared Apache server?

I am looking into deploying a Django project on a shared server running Apache. This is my first time doing this. I have a shared folder on the server for my work and I have been added to the sudo group so I can install new software.
How do I check via Terminal command line if mod_wsgi is already installed? and preferably what version it is?
I can ssh onto the server, the version of Apache is
$ apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 12 2013 13:37:10
$
Any help is much appreciated.
EDIT:
Just for future reference, after I ran the command $ dpkg -s libapache2-mod-wsgi provided by Dirk Eschler it showed me that it was not installed. It returned
Package `libapache2-mod-wsgi' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Hope this helps someone else.
To check if it is installed:
$ dpkg -s libapache2-mod-wsgi
In case it is installed, you might check if it's loaded by Apache:
$ apache2ctl -t -D DUMP_MODULES
Though you are on Ubuntu.
This might help someone else on CentOS, Fedora or Red Hat
rpm -q mod_wsgi
Since you're on Ubuntu, which is Debian-based, you can look in /etc/apache2/mods-enabled.
if you working with python in Red Hat
search this for mod_wsgi installed or not yum search python3-mod_wsgi
or search this for module is loaded or not rpm -q python3-mod_wsgi

When I attempt to runserver, why do I get an ImportError Reason: image not found?

I upgraded from osX 10.7 to 10.9 and all my PostgreSQL database calls started failing.
I upgraded to psycopg2 version 2.5.2 via
$ sudo pip install --upgrade psycopg2
When I try to runserver, I get an importError.
$ python manage.py runserver
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /usr/local/lib/libpq.5.4.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
Reason: image not found
What does this mean?
It seems that Python is attempting to load:
/usr/local/lib/libpq.5.4.dylib
But the file is not there, how do I correct this?
HOW I FIXED IT:
It seems postgreSQL was looking for a file in the wrong location.
So, I installed PostgreSQL 9.3 from a binary.
I think created a symbolic link to the *.dynlib file.
ln -s /Library/PostgreSQL/9.3/lib/libpq.5.6.dylib /usr/local/lib/libpq.5.4.dylib
libpq.5.4.dylib should reside in /Library/PostgreSQL/9.1/lib/.
Try creating a link from /usr/local/lib/libpq.5.4.dylib to /Library/PostgreSQL/9.1/lib/libpq.5.4.dylib
I did note that I have no such link in my own /usr/local/lib, but then I am running 10.6.8.