Monday, August 5, 2013

SSL Install on wamp server

  1. First thing first, we need to create that self-signed SSL certificate, so go to DOS command prompt (Start menu -> Run -> cmd).
  2. ext, we need to navigate to the directory that contains the openssl executive file which is located in folder C:\wamp\bin\apache\apache2.2.14\bin by default. In order to go there, we need to type the command as follows.
Code:
cd\wamp\bin\apache\apache2.2.14\bin
  1. After press Enter, your prompt should change as follows
Code:
c:\wamp\bin\apache\apache2.2.14\bin>

From there, we begin to create the self-signed SSL certificate and the first command you have to type is as follows.
Code:
openssl genrsa -aes256 -out pass.key 2048
  1. After press Enter and wait a little while, it should ask you for a pass phrase. Just type in anything but make sure you have to remember that for later use. Of course, it will ask you to verify the pass phrase.
    You may type test for testing.
  2. Now, we will create the key for our server. In this tutor guide for HTTPS SSL on WAMP, we will use our domain test, but you should use your domain or design name instead.
Code:
openssl rsa -in pass.key -out test.key
  1. Next, it will ask you to enter the pass phrase that you have created before. Wait a little while for it to write the key for your server.
  2. Now is the time to type in the command to create our self-signed SSL certificate; since this command is quite long, you will see it takes more than one line, so make sure not to press the Enter key until you finish the whole command.
Code:
openssl req -new -x509 -nodes -sha1 -key test.key -out test.crt -days 999 -config C:\wamp\bin\apache\apache2.2.14\conf\openssl.cnf
  1. After press Enter, it will ask you to input 2 letters that presents your country. You can enter LK, US, IN, JP, etc... that represents your country. Next you have to input your State or Province, City, Organization Name, Organization Unit Name, Common Name and Email address.
  2. Guess what, you just got yourself a self-signed SSL certificate. Now, open folder c:\wamp\bin\apache\apache2.2.14\conf and create a new folder "ssl" (without quotes).
  3. Then, from folder c:\wamp\bin\apache\apache2.2.14\bin, copy 2 files key and crt to ssl folder. (test.key, test.crt)
  4. Create another folder named as "logs" inside c:\wamp\bin\apache\apache2.2.14\conf\ssl. We save all HTTPS transaction and error logs in this folder.
  5. After that, go to folder c:\wamp\bin\apache\apache2.2.14\conf\extra to open file httpd-ssl.conf.
  6. Find this line:
Code:
SSLSessionCache "shmcb:C:/Program Files/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)"
Replace with:
Code:
SSLSessionCache "shmcb:C:/wamp/bin/Apache/apache2.2.14/conf/ssl/logs/ssl_scache(512000)"
  1. Next find this line:
Code:
SSLCertificateFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.crt"
Remember to substitute expertcore with your domain to replace with:
Code:
SSLCertificateFile "C:/wamp/bin/Apache/apache2.2.14/conf/ssl/test.crt"
  1. Then find:
Code:
SSLCertificateKeyFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.key"
Again, substitute expertcore with your domain to replace:
Code:
SSLCertificateKeyFile "C:/wamp/bin/Apache/apache2.2.14/conf/ssl/test.key"
  1. Then find:
Code:
SSLMutex "file:C:/Program Files/Apache Software Foundation/Apache2.2/conf/ssl/logs/ssl_mutex"
Replace with:
Code:
SSLMutex default
  1. In Virtual Host, find these lines:
Code:
# General setup for the virtual host
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName localhost:443
ServerAdmin admin@localhost
ErrorLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/error_log"
TransferLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/access_log"


HTTPS SSL is the secure transaction which is good for sensitive informations such as Credit card numbers, membership accounts... however, it might slow down your server performances if everything go through it; thus, we suggest that you only set it to the specific directory that you want to use for SSL, and in this example, we use folder ssl:
Code:
# General setup for the virtual host
DocumentRoot "C:/wamp/www/ssl"
ServerName test:443
ServerAdmin admin@localhost
ErrorLog "C:/wamp/bin/Apache/apache2.2.14/conf/ssl/logs/ssl_error.log"
TransferLog "C:/wamp/bin/Apache/apache2.2.14/conf/ssl/logs/ssl_access.log"
  1. Then find:
Code:
<Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
SSLOptions +StdEnvVars
</Directory>

Modify to become as below:
Code:
<Directory "C:/wamp/www/ssl">
SSLOptions +StdEnvVars
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
  1. Then find:
Code:
CustomLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/ssl_request_log" \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
And change it as below:
Code:
CustomLog "C:/wamp/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
  1. Next, open file httpd.conf in folder c:\wamp\bin\apache\apache2.2.14\conf and find these lines:
Code:
# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf


Uncomment the second line, and make sure there is no blank space in front of second line and in the end of first line or your wamp will not run:
Code:
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.conf
  1. After save and close all files, left click on WAMP tray icon and navigate to Apache modules and scroll down until you get ssl_module; then, left click on it to enable SSL on WAMP.
  2. Next, navigate to PHP extensions and scroll down until you get php_openssl; then, left click on it to enable open_ssl on WAMP.
  3. Left click on the WAMP tray icon and click on Restart all services.
  4. After that, open folder C:\wamp\bin\apache\apache2.2.11\bin and copy 2 files libeay32.dll and ssleay32.dll and paste them in folder C:\Windows\System32.
  5. Now is the time to test our HTTPS SSL on WAMP, so open your desire text editor and create a simple webpage index.html which is then saved in folder C:\wamp\www\ssl as follows:
Code:
<html>
<body>
<font size="5" color="red">test SSL successful</font>
</body>
</html>

  1. Now is the time to run the created test file; open your desire browser and input the address bar as below, remember to replace test with your domain or design name:
Code:
https://test....

  1. Oops, error... If using Firefox, you can left click on the line "Or you can add an exception...". Again, left click on the button "Add Exception".
  2. On the popup windows, left click on the button "Get Certificate".
  3. You have to left click on the button "Confirm Security Exception".
  4. The moment of success that show up the red line in your browser.
    SSL successful

Saturday, April 20, 2013

Webservices

There are number of services available, those share / exchange their data over the internet inform of xml, json , wml etc.

Web services is method of communication between two or more computer using same/different language and operating system.

It is defined by the W3C as "a software system designed to support interoperable computer-to-computer interaction over a network"

XML to DOM

Today, XML is used in world wide to transfer the data from one server to another sever. It is more popular as it is independent of operating system. you can define your own tags.

How to Convert XML to DOM?
Following are the  number of function in PHP, which can convert your xml to dom, so that you can access all xml elements and their values.

SimpleXmlElemnet

$xmlString = '
  Arun
  Mohali
  Punjab
  india
';
$domArray = new SimpleXMLElement($xmlString);
echo "
";
print_r($domArray);
echo "
";


XML Tutorial

What is Full Form of XML?
Full Form of XML is  eXtensible Markup Language.


What is Xml?
Xml is a language, used to transport OR store the data. It has not own tag, So you can create tag according to your requirement.


Where XML is used?
It is used in web-services/ Internet technology to transport OR store the data. It is mainly used in web services for transport the data across different server as XML is independent of language and Operating System (OS).


What are the New language created with use of xml?
Following are the languages created with XML

  • XHTML
  • WSDL for describing available web services(WS)
  • WAP/WML as markup languages for handheld devices
  • RSS / ATOM languages for news feeds
  • RDF and OWL for describing resources and ontology


Give an Example of XML

  Arun
  Mohali
  Punjab
  india



What are xml rules?
Following are some rules of xml
  • All elements must have closing tags.
  • All elements are case senstive
  • Must be properly nested
  • It must have root element
  • Attributes values must be quoted
  • Element name can contain letter, number and other character
  • Element name must start with letter
  • Element name cann't contain spaces.

What  are the benefits of xml?
Following are the benefits of xml
  • Simplicity
  • Extensibility 
  • Self Descriptions
  • Independent of OS
  • Transport / Store the data

What is DTD?
Document Type Definition is used to define the building blocks of elements, means its give information about elements and their use.


What is Schema?
It describe about the elements, alternate to DTD.


What are differences between DTDs and Schema?
  • Schema supports variety of data types similar to programming language where as DTD does not supports. In DTD all tags are similar to text.
  • Inheritance and relationship is possible in Schema, but not possible in DTD
  • Grouping one or more elemnets in possile in Schema only.

What is XML parser?
It is software/application that able to check the wellness of XML, validate of XML and read/write/delete the XML elements.


What is DOM?
Document Object Model is an platform and language independent object which is used to process the xml. DOM represent the entire XML in form of tree, where each and every elements and their values are present and make easy to access them.

There is 3 types of DOM
Core DOM: Standard model for any structured document.

HTML DOM: Standard model for HTML document. (use getElmentById or getElemnetByTagName functions to get the data from document)

XML DOM: Standard model for XML document (use xmlHttpRequest is used to deal with data)



What is SAX?
Simple API for Xml parsing.


What is XPath?
XPath  is an expression language which is used for addressing parts of an XML document. Used to navigate through elements and attributes in an XML document.


What is XMLHttpRequest?
It is used to get the data from the server after load the webpage. It is also able to see the request detail means in processing, finished or error.


Why use Namespaces?
Namespaces used to avoid the confliction when having two elements with same name. Actual it group the elements with some name known as namespace name. 

Sunday, April 7, 2013

SSL


Full form of SSL is Secure Sockets Layer.
Secure Sockets Layer is the standard security technology for establishing an encrypted URL between browser and  web server. It ensure that all data passed between them  are integral and private means secure. SSL is industry protocol, used for securites the data. In Transaction all the URL must be SSL. To get SSL in URL (HTTPS), You must get a SSL Certification. you must provide various detail like company name, Name to Certification Authority. They will validate all the data provided by you.


SSL and  TLS are an integral part of most clients(Web browsers) and Websites(Web servers). If a Web site is on a server that supports SSL, SSL can be enabled and specific Web pages can be identified as requiring SSL access. Any Web server(Website) can be enabled by using Netscape's SSL Ref program library which can be downloaded for non-commercial use OR licensed for commercial use.

Working of SSL