Installation SSL in wamp server: Error in httpd-ssl.conf
Asked Answered
S

7

19

I am trying to set ssl on local host i have follwed the http://madurad.wordpress.com/2014/04/25/redirect-http-to-https-with-wamp-server/ and many others but unable to get success. i stuck in the syntax of httpd-ssl.conf. my apache server get down when i set the

<Directory "c:/wamp/www/"> 
   Options Indexes FollowSymLinks  
   AllowOverride all 
   Require all granted 
   SSLOptions +StdEnvVars
</Directory>

i have tried many others like

<Directory "c:/wamp/www/"> 
   SSLOptions +StdEnvVars
</Directory>

what is issue not able to get....

Scrunch answered 7/10, 2014 at 12:45 Comment(2)
Possible duplicate of How do I allow HTTPS for Apache on localhost?Pitarys
2019 Update How do I allow HTTPS for Apache on localhost?Inductee
C
84

How to Configure WAMPServer to use HTTPS SSL

This is not a trivial process. This tutorial will, hopefully, get SSL working for you. However getting it configured correctly once it is working is TOTALLY DOWN TO YOU.

Additional reading for all who travel this road

Ok,

I have based this tutorial on the creation of a site called www.wamphelpers.dev So whereever you see that name change it to the site name you are trying to secure.

I started by creating a unsecured site, in \wamp\www\wamphelpers

added a Virtual Host for that site, in \wamp\bin\apache\apache{version}\conf\extra\httpd-vhosts.conf

<VirtualHost *:80>
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ServerAlias localhost
    <Directory  "c:/wamp/www">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "c:/wamp/www/wamphelpers"
    ServerName wamphelpers.dev
    ServerAlias www.wamphelpers.dev
    <Directory  "c:/wamp/www/wamphelpers">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

Added its domainname to the C:\windows\system32\drivers\etc\hosts

Some virus checkers block access to the HOSTS file so you may need to disable your virus checker, or configure it not to block the hosts file temporarily.

127.0.0.1 wamphelpers.dev www.wamphelpers.dev
::1       wamphelpers.dev www.wamphelpers.dev

Now restart the dnscache as follows from a command windows launched using 'Run as Administrator'

ipconfig /flushdns

Then created a simple script in \wamp\www\wamphelpers\index.php

<?php
    echo 'Hello, this is the WAMPHELPERS.DEV site homepage';
?>

Now to activate the new Virtual Hosts you have defined, edit \wamp\bin\apache\apache{version}\conf\httpd.conf and find this line

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

and remove the # comment character like so

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Save the file.

Now restart Apache and make sure that your simple unsecured Virtually Hosted site is working before continuing.


The openssl toolkit. The openssl.exe, ssleay32.dll and libeay32.dll come with, and are located in, the C:\wamp\bin\apache\apachex.y.z\bin folder This should be all you need to create your self signed certificate !!

HOWEVER: These did not work for me on any of the versions of Apache that I had installed. I always got this error message.

error message

Where the ordinal number changed depending on the apache version folder I was in.

If you get this error dont worry this is what you need to do.

install the latest version of the OPENSSL TOOLKIT

This can be obtained from here

NOTE: Dont use the V1.1 version yet, the PHP team have not yet compiled PHP with these new linkages, so stick to the V1.0.? versions until they do.

Pick the Latest version of 'Win32 OpenSSLv xxx Light' or 'Win64 OpenSSLv xxx Light' to match your installed version of WAMPServer, as this is all you need.

This will download an .exe file which you can run to install this toolkit.

It will ask the following question, I suggest you answer it like this so you dont end up installing something into C:\windows\system32. Afterall this is a toolkit and it changes reasonably often. Best to keep these things seperate and not make them system global.

openssl install suggestion

Once that is installed ( to whichever folder you specified in the install )you should be ready to start the process of generating keys and certificates!


Generate keys and Certificates.

STEP 1: Generate an RSA Private Key

First we need to create ourselves a certificate. The normal (paid for) process is to create your certificate and then pass it to a signing authority. This is why it costs money, as they have to do, due dilligence, to check that you are who you say you are and that site that you will use the certificate on is real and legitimate.

The openssl toolkit is used to generate an RSA Private Key and CSR (Certificate Signing Request) to be used for our Certificate. The first step is to create your RSA Private Key. This key is a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text.

Open up a Command window (Dos box) using [b]Run as Administrator[/b] Change Directory to where you installed the OpenSSL Toolkit above. In my case this is

CD c:\apps\OpenSSL-Win32\bin

Make a folder for the output to be put in ( to keep the bin folder tidy ) I used website

md website

Now enter this command:

openssl genrsa -out website\server.key 2048

This should have created a file in the website folder called server.key, without a pass phrase key, check it exists.

Step 2: Generate a CSR (Certificate Signing Request)

During the generation of the CSR, you will be prompted for several pieces of information. These are the X.509 attributes of the certificate. One of the prompts will be for "Common Name (e.g. server FQDN or YOUR name) []:". It is important that this field be filled in with the fully qualified domain name of the server to be protected by SSL. So if the website to be protected will be https://www.wamphelpers.dev, then enter www.wampheplers.dev at this prompt. I used wamphelper.dev as my ServerName is ServerName wamphelpers.dev

Do not enter anything to the question: A challenge password []:] Just press Enter. If you do enter a passphrase here when you come to start Apache with SSL configured Apache will not start and will give this error message :-

[error] Init: SSLPassPhraseDialog builtin is not supported on Win32

Basically if you do enter a passphrase Apache is supposed to challenge you for that passphrase each time it starts. This is obviously not going to make your life any easier but primarily on windows it does not actually work and will cause Apache to crash when it attempts to ask for the passphrase, with the above error.

The command to generate the CSR is as follows:

openssl req -new -key website\server.key -out website\server.csr


Example question and answers:
Country Name (2 letter code) [AU]:GB
State or Province Name (full name) [Some-State]: Hampshire
Locality Name (eg, city) []: Portsmouth
Organization Name (eg, company) [Internet Widgits Pty Ltd]: Wamp Helpers Ltd
Organizational Unit Name (eg, section) []: Information Technology
Common Name (e.g. server FQDN or YOUR name) []: wamphelpers.dev
Email Address []: [email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: ( leave blank just hit the enter key )
An optional company name []: ( leave blank just hit the enter key )

Step 3: Generating a Self-Signed Certificate

At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test your new SSL implementation while the CA is signing your certificate.

PRE - WARNING This certificate will generate an error in the client browser to the effect that the signing certificate authority is unknown and not trusted. This is unavoidable as we are signing the certificate ourselves, but of course the web of trust does not know who we are. See example later in this document showing how to tell your browser that you actually trust this certificate

openssl x509 -req -days 365 -in website\server.csr -signkey website\server.key -out website\server.crt


Example output:
Loading 'screen' into random state - done
Signature ok
subject=/C=GB/ST=Hampshire/L=Portsmouth/O=WampHelpers Ltd/OU=Information Technology/CN=www.wamphelpers.dev/[email protected]
Getting Private key

Step 4: Installing the Private Key and Certificate

Create these 2 directories under the version of Apache you are using.

md c:\wamp\bin\apache\apachex.y.z\conf\ssl.key
md c:\wamp\bin\apache\apachex.y.z\conf\ssl.crt

And copy the file we have just generated into them like so:

copy website\server.crt c:\wamp\bin\apache\apachex.y.z\conf\ssl.crt
copy website\server.key c:\wamp\bin\apache\apachex.y.z\conf\ssl.key

Step 5: Configure Apache to activate SSL

Edit httpd.conf, Check that this line is uncommented

LoadModule authn_socache_module modules/mod_authn_socache.so

LoadModule ssl_module modules/mod_ssl.so

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Remove the comment '#' from this line also

Include conf/extra/httpd-ssl.conf

Then move that line after this block .... like so

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf

Step 6: Configure PHP to activate SSL

Edit your php.ini ( use the wampmanager menus so you edit the correct one )

Remove the comment ';' from this line

extension=php_openssl.dll

Step 7: Configure your secure sites Virtual Host

Yup for all you Virtual Host nay sayers, now you cannot avoid the process.

Edit \wamp\bin\apache\apachex.y.z\conf\extra\httpd-ssl.conf

This file is released by Apache and contains some default file location. We can leave most of this file as it is, but we need to configure the virtual host in here to match our actual sites location and a few other things so:

find these lines

DocumentRoot "c:/Apache2/htdocs"
ServerName www.example.com:443
ServerAdmin [email protected]
ErrorLog "c:/Apache2/logs/error.log"
TransferLog "c:/Apache2/logs/access.log"

and change them to

DocumentRoot "c:/wamp/www/wamphelpers"
ServerName wamphelpers.dev:443
ErrorLog "c:/wamp/logs/ssl_error.log"
TransferLog "c:/wamp/logs/ssl_access.log"

Find

SSLCertificateFile "c:/Apache2/conf/server.crt"

and change to

SSLCertificateFile "c:/wamp/bin/apache/apachex.y.x/conf/ssl.crt/server.crt"

Find

SSLCertificateKeyFile "c:/Apache2/conf/server.key"

and change to

SSLCertificateKeyFile "c:/wamp/bin/apache/apachex.y.x/conf/ssl.key/server.key"

Find

<Directory "c:/Apache2/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

and change to

Apache 2.2 Syntax

<Directory "c:/wamp/www/wamphelpers">
    SSLOptions +StdEnvVars
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1 localhost ::1
</Directory>

Apache 2.4 Syntax

<Directory "c:/wamp/www/wamphelpers">
    SSLOptions +StdEnvVars
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require local
</Directory>

Find

SSLSessionCache        "shmcb:c:/Apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

and change it to

SSLSessionCache        "shmcb:c:/wamp/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

Find

CustomLog "c:/Apache24/logs/ssl_request.log" \
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

and change to

CustomLog "c:/wamp/logs/ssl_request.log" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

Basically look through the conf file and any command that is not commented out, but has a reference to a file or folder should be changed to reference the WAMPServer folder structure and not 'C:/Apache2....'

Now make sure all these files we have changed are saved, and restart Apache using the wampmanager menus.

First test that the unprotected site is still working.

Then try using your new protected site by adding the 'https://' to the front of the domain name i.e. https://www.wamphelpers.dev without the single quotes of course.

If Apache does not restart you have probably spelt something wrong. Test the configs like so :-

Open a command window

cd \wamp\bin\apache\apachex.y.z\bin
httpd -t

This will parse all the config files and should give you a file name and a line number where an error has been found.

Fix it and try again.

First access to your site will generate a message page something like this. This is using FireFox, others will be slightly different, but the concept it the same.

enter image description here

This is because your certificate is not signed by a trusted authority, DONT PANIC, this is supposed to happen.

Click on, 'I Understand the risk' and that will show you a button saying 'Add Exception' Press the Add Exception button, after checking that the certificates site details are in fact yours, and you will not see this message again unless you clear the exception list.

BIG NOTE As of Apache v2.2.12 and OpenSSL v0.9.8j it is now possible to secure more than one site per Apache instance. This tutorial does not cover that process. See here for more details:

Here

and Here

and Here

And like I said at the top, now you need to do some reseach on all the options available in the SSL config and make thing work as you want rather than using the default.

Calefaction answered 8/10, 2014 at 8:24 Comment(24)
Also, at the beginning near where you add the virtual hosts you need to make sure the line in httpd.conf that says "Include conf/extra/httpd-vhosts.conf" is uncommented. The file is located in: C:\wamp\bin\apache\apache{version}\confConventioner
@Conventioner Thanks added a not about thatCalefaction
It's really very helpful, thanks for your effort. But I think, there is problem in Find section of CustomLog "c:/wamp/logs/ssl_request.log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"Numskull
@Numskull Thanks, I fixed it I believeCalefaction
Wow, worked like a charm. Yknow when you edit so many config files, I was scared it wouldn't work because you can't really check half way....but it did. The only thing, in apache 2.4.x you need to uncomment the "LoadModule socache_shmcb_module modules/mod_socache_shmcb.so", but thats it!Mattland
I received the error refused to connect ERR_CONNECTION_REFUSED when loading my dev site on http and https, and in Windows Application log I saw The Apache service named reported the following error: >>> AH00526: Syntax error on line 73 of D:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-ssl.conf,. Line 73 said SSLSessionCache "shmcb:d:/wamp/logs/ssl_scache" which was resolved by uncommenting LoadModule socache_shmcb_module modules/mod_socache_shmcb.so in http.conf, as learnt from this answerTragedy
Otherwise, thank you so much for this answer Riggs. Saved me a lot of time and confusion.Tragedy
@Tragedy Thanks for the feedback, I have added missed module to the process.Calefaction
If you already a key and certificate file you can just copy those and skip the OPENSSL TOOLKIT installation step if all settings and paths in step 1-3 are the same. Just continue from step 5.Shellieshellproof
"I have based this tutorial on the creation of a site called www.wamphelpers.dev. So whereever you see that name change it to the site name you are trying to secure..." - you usually use example.com. www.wamphelpers.dev can be a real name, and IANA reserved example.com for the purpose.Negron
"Generating a Self-Signed Certificate..." - this section is mostly wrong, and it will produce a certificate that fails to validate under some user agents. Hostnames (including IP addresses) always go in the SAN. If its present in the CN, then it must be present in the SAN too (you have to list it twice in this case). For more rules and reasons, see How do you sign Certificate Signing Request with your Certification Authority and How to create a self-signed certificate with openssl?Negron
worked really well, need to uncomment this line LoadModule socache_shmcb_module modules/mod_socache_shmcb.so , in apache 2.4 it is commented by default. you may add this.Thermoelectricity
@RiggsFolly, I have tired your steps, https:// is not working, but http:// is working, any idea why?Hoad
Please define Not working and maybe show any error messagesCalefaction
Just wanted to say thank you. After countless of hours trying, it worked. My god. Thank you sir.Triplet
Wow, i've been struggling for days to achieve this on a Windows 10 copy, this is the REAL solution. Thank you so much.Baucis
C:/wamp/bin/apache/apache2.4.17/conf/httpd.conf: Cannot load modules/mod_ssl.so into server: O sistema operacional n\xe3o pode executar %1Lylalyle
Worked! Thanks for the post!Botanical
WOW! Thanks so much, RiggsFolly, for posting such a detailed and well-explained answer! This really helped me in setting up SSL on my WAMP!! :DKaye
This is by far the best explanation I have found all day! This works in Wamp64 as well, for anyone wondering.Androw
this is probably the best and most comprehensive correct answer I've ever seen on this website, thank you for this, still working for wamp3.2.6Ravishing
@Ravishing Thanks for the feedback. By the way WAMPServer 3.2.7 is now out :)Calefaction
@Calefaction very nice guide, i always use this thread when setting up my SSL for wamp. The only thing i am missing is to setup multiple SSL vhosts it would be really nice if you could expand this guide with the steps to add them.Gamy
@Gamy I will see what I can do :)Calefaction
C
5

It is necessary activate the module LoadModule socache_shmcb_module modules/mod_socache_shmcb.so in the file httpd.conf in wampserver 2.5. If not apache throws the next message:

AH00526: Syntax error on line 75 of C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-ssl.conf: SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).

Cache answered 24/11, 2015 at 22:24 Comment(0)
S
3

@RiggsFolly: some small errors/typos/additions in your tutorial. Below is used in combination with WAMPServer 2.5 64bits (Apache 2.4.9 and PHP 5.5.12) on Windows 7 SP1 64bits:

-httpd-vhosts.conf is located in extra/httpd-vhosts.conf

-when you try to edit your hosts file be sure to disable any virusscanner. Some of them block access to hosts file.

-be sure to open your texteditor as administrator when editing your hosts file or else you get an error trying to save.

-don't forget to remove # at the beginning of the host line if any

-if you use WAMPServer 64bit be sure to download the 64bit version of OpenSSL

-the step openssl genrsa -out website\server.key 2048 creates a server.key file and not a privkey.pem!

-file \wamp\bin\apache\apachex.y.z\conf\httpd-ssl.conf is located at \wamp\bin\apache\apachex.y.z\conf\extra\httpd-ssl.conf (maybe this depends on the WAMPServer version)

-I had to use different ports for http (80->8080) and https(443->444) as these ports where used by I think Skype. When you use different ports be sure to use these everywhere you see 80 or 443 in this tutorial

-I also had to enable socache_shmcb_module. The "httpd -t" also mentioned this.

Shellieshellproof answered 25/2, 2015 at 9:58 Comment(0)
P
3

If you have the error something like this:

Cannot load modules/mod_ssl.so into server: The specified module could not be found.

  1. You may want to try to searching libeay32.dll in your wamp folder, you probably find it in {wamp folder}/bin/php/php{version 7}/

  2. Copy libeay32.dll and ssleay32.dll and paste them into {wamp folder}/bin/apache/apache{version 2.x}/bin/ AND {wamp folder}/bin/php/php{verion 5.x}. MAKE SURE you backup anything you are placing.

  3. run httpd -t and test the syntax

NOTE: I believe it is due to the mistake in apache openssl part for wamp 3.0.6. Fortunately in php7 folder those dlls are compatible for the apache and php5.

Prelusive answered 18/9, 2016 at 14:51 Comment(0)
P
1

@RiggsFolly: Self-signed certificate with key could be easily generated for example here... http://www.selfsignedcertificate.com/, so I could start the tutorial from step 4 (I also had standard :80 virtual server running).

Anyways some mentioned things were already enabled in default WAMP installation (I guess it changes from version to version), but the rest helped me a lot. And actually one thing was missing... I also had to uncomment the following line in "httpd.conf"

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Pitfall answered 25/11, 2014 at 9:3 Comment(0)
K
1

If you have the error :

Cannot load modules/mod_ssl.so into server: The operating system cannot run %1

Then you have to :

  1. Install Win32 OpenSSL here http://slproweb.com/products/Win32OpenSSL.html
  2. Copy / paste libeay32.dll, ssleay32.dll into your wamp php bin folder (C:\wamp64\bin\php\php5.6.19)
  3. Restart apache

Note: Tested on Wamp server 3

Kevenkeverian answered 20/7, 2016 at 13:6 Comment(4)
I tried this, but I didn't found libeay32.dll or ssleay32.dll inside the openssl directoryKraken
I didn't find libeay32.dll or ssleay32.dll inside C:\OpenSSL-Win64 either. But replacing these two symlinks in c:\wamp\bin\apache\apache2.4.18\bin with a copy of the files from c:\wamp\bin\php\php7.0.4 worked for me.Quadruplicate
@Aydus-Matthew OMG that did it for me , been banging my head around for days ... almost gave up ... TNXCursorial
@Aydus-Matthew , the love I have for you right now is realHydraulic
I
1

Before all:

1).Shutdown WAMP and proceed to C:\wamp\scripts\config.inc.php move from array libeay32.dll,ssleay32.dll, lines 133,139

2).Install OpenSSL from official site,pay attention on version of the your OS x64 or not.

Command prompt:

3).cd C:\wamp\bin\apache\apache2.4.23\bin

4). openssl req -new > localhost.csr

5). openssl rsa -in privkey.pem -out localhost.key

6). openssl x509 -in localhost.csr -out localhost.crt -req -signkey localhost.key -days 365 -sha256 -extfile v3.ext

Update: from Chrome 58 we will need to provide Subject Alternative Name. This name we can obtain from extension file v3.ext:

authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = 127.0.0.1
DNS.2 = localhost

Very important in Common Name to insert 'localhost'

7).Grab localhost.key and localhost.crt and put them to C:\wamp\bin\apache\apache2.4.23\conf\key (sure,before create appropriate directory)

Configuration:

8).enable in C:\wamp\bin\apache\apache2.4.23\bin\php.ini and

C:\wamp\bin\php\php5.6.25\php.ini extension=php_openssl.dll

9).proceed to C:\wamp\bin\apache\apache2.4.23\conf\httpd.conf and uncomment:

LoadModule ssl_module modules/mod_ssl.so,

Include conf/extra/httpd-ssl.conf,

Include conf/extra/httpd-vhosts.conf,

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so 

10). proceed to C:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-ssl.conf

and make changes :

SSLSessionCache "shmcb:c:/wamp/bin/apache/apache2.4.23/logs/ssl_scache(512000)" ,

SSLSessionCacheTimeout 300,

VirtualHost _default_:443,

DocumentRoot "c:/wamp/www/",

ServerName localhost:443,

ErrorLog "c:/wamp/bin/apache/apache2.4.23/logs/ssl_error.log"

, (create file if not exists)

TransferLog "c:/wamp/bin/apache/apache2.4.23/logs/access.log",

SSLCertificateFile "c:/wamp/bin/apache/apache2.4.23/conf/key/localhost.crt",

SSLCertificateKeyFile "c:/wamp/bin/apache/apache2.4.23/conf/key/localhost.key",

<Directory "c:/wamp/www/">
    SSLOptions +StdEnvVars
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require local
</Directory>

,

  CustomLog "c:/wamp/bin/apache/apache2.4.23/logs/ssl_request.log"

Certificate handling:

11).press Win+R and insert 'certmgr.msc',import servercert.crt into 'Trusted Root Certificated Authorities'

12). Check your server in command prompt 'httpd -t' should be 'Syntax OK'

13). Launch Wamp and proceed to link https://localhost

I am hope this will help

Note: please read this article about Mozilla behavior :

https://blog.mozilla.org/security/2014/09/23/phasing-out-certificates-with-sha-1-based-signature-algorithms/
Inapproachable answered 8/5, 2017 at 19:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.