11:44:03pm
Xampp and SSL Encryption
XAMPP: SSL Encrypt the Transmission of Passwords with https
This article is part of a series of articles about making XAMPP more secure. See the overview page for all the security measures.
If you don’t have encryption enabled on a password protected folder, the password will be sent in cleartext - meaning that it can be seen by anyone using a network sniffer. It is a good idea to encrypt the transmission of these passwords. There are 2 steps to this process, first we need to create SSL certificates, and then we need to make sure that the password protected pages are only accessed with encryption. It’s also a good idea to import your certificates into any browsers on all machines that you plan to use to access your server, otherwise you’ll get a warning about an untrusted certificate authority.
Create SSL Certificate and Server Private Key
In order to enable the encryption of your password, you must create an SSL certificiate (containing your public key) and a server private key. XAMPP provides a default certificate/key that can be used, but it is better to create a new one since the default key is available to anyone who downloads XAMPP. If someone knows your key, they can decrypt your packets.
XAMPP provides a batch file for creating a new certificate/key with random encryption keys. To execute this batch file, do the following:
- Open a command window (Start->Run, type “cmd” and press “OK)
- cd c:\xampp\apache
- makecert
You will then see this:
C:\xampp\apache>newcert
loading screen into random state - done
generating data 1024 bit RSA private key
................................................+++++++++
....................................................................++++++++
writing new private key to privkey.pem
enter PEM pass phrase:
Enter in a pass phrase for encrypting your private server key, and press enter. write down this passphrase so you don't forget it. now you will be asked to verify it:
verifying - enter PDM pass phrase:
enter your passphrase a second time and hit enter. Now, you'll see this:
------
you are about to be asked to enter information that will be incorporated
into your certificate request.
What you're about to enter is what is called a Distinguished name or as DN.
for some fields there will be a default value,
if you enter '.', The field will be left blank.
------
Country Name (2 letter code) [AU]
enter in your 2 letter country code. You'll be asked for a few more items (shown below). enter is what you think is most appropriate, . When you are asked for "Common Name"
State or Province Name (full name) [Some-State] :NY
Locality Name (eg, city) []: New York
Organization Name (eg, company) [Internet Widgets Pty Ltd] : Rob's Great Company
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
For "Common Name", you need to enter in the DNS name or IP address of your website. The name that you enter in here will need to match the server name that is entered into the browser that is accessing the page. It is important that this common name match the address that goes into a browser, otherwise you will get extra warnings when navigating to your secure webpages. If you are running this website over the public Internet on a IP address that changes sometimes, you can use I then now make DNS service such as dyndns.org to get a free domain name that always points to your server. After you enter into "Common Name", you are asked for more information. Fill in what you think is appropriate, but it is okay to just hit enter to accept the defaults. Eventually, you will be asked for a pass phrase for privkey.pem:
E-mail Address []:
Please enter to following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Enter pass phrase for privkey.pem:
Enter the pass phrase that you created earlier, and now you will see this:
writing RSA key
loading 'screen' into random state - done
signature ok
subject=/C=xx/ST=xx/L=XXXX/O=xxx/CN=commonname
Getting Private key
You are now finished creating your SSL certificate and private key. The makecert.bat script will move your server private key and certificate in their appropriate directories for you.
Import the certificate into the browser for each client
since this certificate is self signed, and is not sign by a well-known certificate authority (CA), when you browse to the protected pages you'll get a warning. To turn off this warning, this certificate should be imported as a trusted CA into any browsers that you willuse to access your server.
Importing the certificate into IE 7
Here are dispatched to import the certificate into IE 7:
Tools->Internet Options
Content Tab->Certificates button
Trusted Root Certification Authorities Tab-> Import Button
now you see the "Certificate Import Wizard"
Click Next
Leave the default to Place all certificates in certificate store: Trusted Root Certification Authorities, and click next
click finish
Importing the certificate into Firefox 2 and above:
here are the steps to import the certificate into Firefox two and above:
Tools-> Options
Advanced->Encryption Tab-> View certificates button
Authorities Tab-> Import button
Select file: C:\xampp\Apache\conf\ssl.crt\server.crt, and click "Open"
Check "Trust this CA to identify web sites"
click "ok"
click "ok" in certificate manager
click "ok" in original Options window to get back into Firefox
Edit Apache config for encryption only access to password-protected folders
now we will instruct Apache to access the password-protected folders with SSL encryption exclusively. This is done in two steps. First, we set up the Apache config files for these folders to say they can only be accessed with SSL decryption. Next, we redirect any HTTP traffic to these pages to HTTPS (this is optional).
Make folders accessible with SSL encryption only
first, we need to inform Apache that the folders you want to encrypt should always use encryption ( and never go into the clear). This is accomplished by putting an SSLrequireSSL draft of inside of each desired <directory> listing in the config files ( it is okay to put it at the end, just before the </directory>). The red text below shows what to do.
Alias /Web folder name "C:/xampp/folder name"
<directory "C:/xampp/foldername">
....
....
SSLrequireSSL
</directory>
I suggest doing this for the following folders (if you still have them):
- Config File: c:\xampp\apache\conf\extra\httpd-xampp.conf
- -c:\xampp\phpmyadmin
- -c:\xampp\htdocs\xampp
- -c:\xampp\webalizer
- -c:\xampp\security\htdocs
- Config File: c:\xampp\webdav
- -c:\xampp\webdav
Redirect “http” to “https” for certain folders
This next optional step is to redirect “http” requests to “https” requests for the pages we want to secure. This is more user friendly and allows you to still use http when you type in the address (and automatically switch to https:// and encryption). If you don’t do this, and you used SSLRequireSSL, you will only be able to access these pages by typing https://. This is fine and probably a little bit more secure, but is not so user friendly. To accomplish the redirection, we will use mod_rewrite so that we don’t have to use the server name in this part of the config file. This helps keep small the number of places in the config files where the server name is written (making your config files more maintainable).
First, we need to make sure that mod_rewrite is enabled. To do this, edit c:\xampp\apache\conf\httpd.conf and get rid of the comment (# character) in this line:
#Loadmodule rewrite_module modules/mod_rewrite.so
to make it look like this:
Loadmodule rewrite_module modules/mod_rewrite.so
Now, paste the following text into the top of C:\xampp\Apache\conf\extra\httpd.conf:
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect /xampp folder to https
RewriteCond %{HTTPS} !=On
RewriteCond %{REQUEST_URI} xampp
RewriteRule ^(.*) https://%(SERVER_NAME)$1 [R,L]
# Redirect /phpMYAdmin folder to https
RewriteCond %{HTTPS} !=On
RewriteCond %{REQUEST_URI} phpmyadmin
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /security folder to https
RewriteCond %{HTTPS} !=On
RewriteCond %{REQUEST_URI} securit
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /webalizer folder to https
RewriteCond %{HTTPS} !=On
RewriteCond %{REQUEST_URI} webalizer
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
</IfModule>
if you have other folders you want to redirect to a https://, add the generic text below ( but substitute your folder name):
# Redirect /folder_name folder to https
RewriteCond %{HTTPS} !=On
RewriteCond %{REQUEST_URI} folder_name
RewriteRule ^(*) https://%(SERVER_NAME)$1 [R,L]
If you are going to host a webdav server, it is probably best to not have this redirection and to just require https://. This way people can only use https:// when addressing your webdav folder. I tried using redirection for a webdav server and giving http:// in both XP and Mac OS X, and it didn't work when encryption was required.
One thing to keep in mind with this redirection is that if you have virtual hosts, you need to place their redirection code ( with the RewriteCond and RewriteRule) inside of your virtual host declarations, otherwise their redirection won't work.
How to install ffmpeg, mencoder, mplayer and php-ffmpeg on windows server
First you have to download all the required files which can be found here
FFMPEG
click to download
(download the zip,rar or 7z extension file)
MENCODER
click here to download
(download the zip,rar or 7z extension file)
CODECS FOR MPLAYER
click here to download
(download the zip,rar or 7z extension file)
PHP-FFMPEG
click here to download
(download the zip,rar or 7z extension file. this will not work on php 5.3)
extract all the files you have download in separate folders in a temp directory.
1) copy ffmpeg to c:\ffmpeg (you can choose any path)
2) copy mencoder to c:\mencoder (you can choose any path)
3) copy mplayer codecs in c:\mencoder\codecs (all the codecs should be in that codecs folder of mencoder)
4) copy all php-ffmpeg to windows\system32 and php\ext (extension folder)
5) open php.ini and add extension=php_ffmpeg.dll (to locate php.ini file loaded make a temp php file and put run that file in the webserver and look for php.ini file)
6) restart web server and thats it.

