title: How to compile Python 3.6 with custom Fips enabled Openssl?
body: <p>This is a follow up question to <a href="https://stackoverflow.com/questions/49493537/how-to-implement-fips-mode-and-fips-mode-set-in-python-3-6s-ssl-module/49494549?noredirect=1#comment86061294_49494549">this SO question</a> where i was having problems in patching Python 3.6. Now that i have managed to patch python and introduce the FIPS_mode() and FIPS_mode_set() in Python, i need to compile it with a custom openssl with fips mode which is located in <strong>/usr/local/ssl</strong>. Another OpenSSL (system) is also installed by default.</p>
  
  <p><strong>Details: Ubuntu 16.04 LTS</strong></p>
  
  <p><strong>Python: 3.6</strong></p>
  
  <p><strong>OpenSSL: 1.0.2h with FIPS 2.0.12</strong></p>
  
  <p>I run this command on the terminal:</p>
  
  <pre><code>./configure --enable-shared --prefix=/usr/local/python3.6 &amp;&amp; make &amp;&amp; make install
  </code></pre>
  
  <p>Python gets compiled successfully but when with i import the ssl module and print the openssl version, it shows me the System's Openssl version which is 1.0.2g. In addition to this, the FIPS_mode() and FIPS_mode_set() methods are not exported because they do not exist in the underlying libcrypto.so and libssl.so.</p>
  
  <p>After some digging i found this <a href="https://tuannvm.github.io/blogs/how-to-compile-python-with-custom-openssl-version/" rel="nofollow noreferrer">article</a> which told me to replace the libcrypto.so and libssl.so shared objects in <strong>/lib/x86_64-linux-gnu/</strong>. If i replace these with the fips enabled libcrypto.so and libssl.so shared objects then python compiles successfully and shows the correct version and even the FIPS functions are being imported properly but this is causing other applications to misbehave in the system.</p>
  
  <p>Is there a way to compile Python in such a way that it looks for the libcrypto.so and libssl.so shared objects from other locations such as /usr/local/ssl?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Update:</strong></p>
  
  <p><strong>I managed to find a solution for this and have documented it <a href="https://hussainaliakbar.github.io/build-python-3-6-0-from-source-with-fips-validated-openssl-on-ubuntu-16-04-lts/" rel="nofollow noreferrer">here</a> in case someone else faces this problem as well.</strong></p>