Merge pull request #1282 from akgood/reorder_libs

Reorder OpenSSL libraries on the linker command-line
diff --git a/cryptography/hazmat/bindings/openssl/binding.py b/cryptography/hazmat/bindings/openssl/binding.py
index 4cd1b89..4cbe3c5 100644
--- a/cryptography/hazmat/bindings/openssl/binding.py
+++ b/cryptography/hazmat/bindings/openssl/binding.py
@@ -96,7 +96,11 @@
         # OpenSSL goes by a different library name on different operating
         # systems.
         if sys.platform != "win32":
-            libraries = ["crypto", "ssl"]
+            # In some circumstances, the order in which these libs are
+            # specified on the linker command-line is significant;
+            # libssl must come before libcrypto
+            # (http://marc.info/?l=openssl-users&m=135361825921871)
+            libraries = ["ssl", "crypto"]
         else:  # pragma: no cover
             link_type = os.environ.get("PYCA_WINDOWS_LINK_TYPE", "static")
             libraries = _get_windows_libraries(link_type)