HsOpenSSL Update

The maintainer of HsOpenSSL accepted a patch Job Vranish and I put together that moves to a simple build type rather than the configure step. This has the nice side effect that, with the right libraries installed, we can get HsOpenSSL to install happily in windows without the need for Cygwin to build it.

Here’s how:

  1. First, we need to install the OpenSSL binaries and header files. The Windows build of OpenSSL depends on the Visual C++ 2008 Redistributables. Download and install them.
  2. Next we need the Win32 OpenSSL v0.9.8k package. Download and install this.
  3. Open cmd.exe to run a few commands.
  4. Now that OpenSSL is installed, lets perform a cabal update to make sure we have the most recent package.
  5. If you used the default installation options, you can call the following command to install HsOpenSSL:
    cabal install --reinstall HsOpenSSL --extra-include-dirs=C:OpenSSLinclude --extra-lib-dirs=C:OpenSSLlibMinGW

    Note that I included --reinstall just to make sure we don’t terminate prematurely because of an older version.

Everything should be installed now. Lets test it. Save this into a file somewhere:

module Main where

import OpenSSL.RSA

main :: IO ()
main = do
    key <- generateRSAKey' 2048 65537

    print key

And lets build it…

ghc --make test.hs

…and run it…

>test.exe
RSAKeyPair {rsaN = [ZOMG BIG NUMBER], rsaE = 65537, rsaD = [ZOMG ANOTHER ONE], rsaP = [THIS ONE WASN'T AS LARGE], rsaQ = [SAME HERE, BUT STILL PRETTY HUGE] }

If you got some output that wasn’t an error from test.exe, you’ve successfully installed HsOpenSSL in Windows.

Hope this helps someone!

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to HsOpenSSL Update

  1. Ivan Perez says:

    Thanks for the post 🙂

    Unfortunately, I was unable to compile HsOpenSSL using the files provided by slproweb (the current link is dead, there’s a new link posted on their website). I was able to compile HsOpenSSL using the files provided by the gnuwin32 project at sf (gnuwin32.sourceforge.net). That version is outdated and probably contains a few bugs, although for my current purposes that should not be relevant (I’m not generating keys or using passwords, just verifying signed keys).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s