Please note that commercial SSL certificates require a unique IP address each for SSL-enabled site, although multiple non-SSL sites may also share that IP address.
Step – 1 Create a Certificate Signing Request
A CSR is an encrypted body of text. Your CSR will contain encoded information specific to your company and domain name; this information is known as a Distinguished Name or DN.
In the DN for most servers are the following fields: Country, State (or Province), Locality (or City), Organization, Organizational Unit, and Common Name. Please note:
1. The Country is a two-digit code -- for the United States, it's 'US'. For countries outside of the United States,
2. State and Locality are full names, i.e. 'California', 'Los Angeles'.
3. The Organization Name is your Full Legal Company or Personal Name, as legally registered in your locality.
4. The Organizational Unit is whichever branch of your company is ordering the certificate such as accounting, marketing, etc.
5. The Common Name is the Fully Qualified Domain Name (FQDN) for which you are requesting the ssl certificate.
If you are generating a CSR for a Wildcard Certificate your common name must start with *. (for example: *.digicert.com). The wildcard character (*) will be able to assume any name that does not have a "dot" character in it.
To remain secure, certificates must use keys which are at least 2048 bits in length. If your server platform can't generate a CSR with a 2048-bit key
[sourcecode language="php"]
mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
openssl req -new -newkey rsa:2048 -nodes -keyout yourdomain.key -out yourdomain.csr
[/sourcecode]
Replace yourdomain with the domain name you're securing. For example, if your domain name is viralsolani.co, you would type viralsolani.co.key and viralsolani.co.csr.
• This begins the process of generating two files: the Private-Key file for the decryption of your SSL Certificate, and a certificate signing request (CSR) file (used to apply for your SSL Certificate) with apache openssl.
• Open the CSR file with a text editor and copy and paste it (including the BEGIN and END tags) into the form from where you purchase your SSL certificate.
• Save (backup) the generated .key file as it will be required later for Certificate installation
Execute the following command to protect the key:
chmod 400 /etc/apache2/ssl/www.yourdomain.com.key
Execute the following command to protect the signed certificate:
[sourcecode language="php"]
chmod 400 /etc/apache2/ssl/www.mydomain.com.crt
[/sourcecode]
Step – 2 Get the Certificate Authority Root Certificate
In My case it is Go Daddy. So you need to go from wherever you purchase your SSL certificate and you need to submit the below generated CSR. And you can then download the certificate.
You will get two files. I’ve upload that two files in same folder where I’ve put my CSR and Private key that i.e /etc/apache2/ssl/
Step – 3 Configure Apache to use the Signed SSL Certificate.
This configuration vary depend upon OS and version of that OS. So I’ve installed Ubuntu 12.04 and to configure the certificate you need to do below steps.
You need to configuration in Apache virtual hosting file.
So now you need to go: /etc/apache2/sites-available/default-ssl
[sourcecode language="php"]
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin viral.solani@gmail.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/apache2/ssl/yourdomain.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/yourdomain.com.key
SSLCertificateChainFile /etc/apache2/ssl/gd_bundle.crt
</VirtualHost>
</IfModule>
[/sourcecode]
Basically you need to locate yourdomain.com.crt , yourdomain.com.key and gd_bundle.crt.
Now last thing you need to do is restart you apache with the following command
[sourcecode language="php"]
/etc/init.d/apache2 restart
[/sourcecode]
You should now be able to visit your site with SSL enabled. Congratulations, you've installed a commercial SSL certificate!
Blog contains various PHP, Javascript Code that would be helpful for website development. PHP is a open source scripting language useful to develop dynamic website.
Wednesday, 6 February 2013
Monday, 28 January 2013
2012 in review
Thursday, 6 December 2012
Understanding Abstract Classes in PHP
Abstract classes are an often misunderstood feature of PHP object-oriented programming (OOP) and the source of confusion when considered versus an Interface. The obvious reason for using an Interface is that a child class can implement multiple interfaces but extend only a single abstract class. However, if multiple inheritance is not required then people often go with abstract classes just because they provide the option of later adding base functionality within the abstract class. This is not entirely unreasonable but the reasons for creating abstract classes should be more than that.
Why Use Abstract Classes?
An Abstract class provides concrete base functions as well as abstract functions that must be implemented by concrete child classes—binding them into a contract so to speak, if they wish to make use of the base functionality.
This is a subtle but important point and this is where abstract classes really shine. They can call abstract functions from within base concrete functions. Jumping straight to an example is the clearest way to explain this.
[sourcecode language="php"]
abstract class Animal {
function greeting() {
$sound = $this->sound(); // exists in child class by contract
return strtoupper($sound);
}
abstract function sound(); // this is the contract
}
class Dog extends Animal {
function sound() { // concrete implementation is mandatory
return "Woof!";
}
}
$dog = new Dog();
echo $dog->greeting(); // WOOF!
[/sourcecode]
This opens up a whole lot of interesting possibilities. For example, you can write a drive() function that calls $this->start(); $this->accelerate(); in an abstract class. Then create a motorcycle class that defines its own start() and accelerate() functions that may be different from those in the car class. In turn, the motorcycle and car can both be driven by just calling drive() without having to implement it locally.
Characteristics of Abstract Classes
Make a note of these characteristics to lock down your understanding of abstract classes:
Why Use Abstract Classes?
An Abstract class provides concrete base functions as well as abstract functions that must be implemented by concrete child classes—binding them into a contract so to speak, if they wish to make use of the base functionality.
This is a subtle but important point and this is where abstract classes really shine. They can call abstract functions from within base concrete functions. Jumping straight to an example is the clearest way to explain this.
[sourcecode language="php"]
abstract class Animal {
function greeting() {
$sound = $this->sound(); // exists in child class by contract
return strtoupper($sound);
}
abstract function sound(); // this is the contract
}
class Dog extends Animal {
function sound() { // concrete implementation is mandatory
return "Woof!";
}
}
$dog = new Dog();
echo $dog->greeting(); // WOOF!
[/sourcecode]
This opens up a whole lot of interesting possibilities. For example, you can write a drive() function that calls $this->start(); $this->accelerate(); in an abstract class. Then create a motorcycle class that defines its own start() and accelerate() functions that may be different from those in the car class. In turn, the motorcycle and car can both be driven by just calling drive() without having to implement it locally.
Characteristics of Abstract Classes
Make a note of these characteristics to lock down your understanding of abstract classes:
- Single inheritance. Child classes can extend only one class at a time.
- Abstract classes cannot be instantiated — no new Animal();
- Abstract classes can define class variables of type const only.
- Abstract class A can be extended by another abstract class B. Abstract class B can implement none or any of the abstract functions in A.
- In the previous case, a child class C which extends abstract class B must implement all abstract functions in B as well as the abstract functions in A which have not already been implemented in B.
- The signature of the concrete functions and abstract functions must be the same. However, if an abstract function is defined as abstract function speak($greeting); then it is okay to implement it as function speak($greeting, $shout = FALSE) but not function speak($greeting, $shout).
- The visibility of functions in the child classes must be the same or less restrictive than the parent class. Thus, a protected abstract function can be implemented as either protected or public but not private.
Declaring functions as static abstract throws a strict warning in PHP 5.2 or earlier, however, as of PHP 5.3 this is allowed.
Wednesday, 26 September 2012
Add JSON objects ,arrays and variables from php to javascript in Zend Framework
Superb way of adding PHP variables to Javascript/Jquery in Zend Framework
Wednesday, 30 May 2012
Subscribe to:
Posts (Atom)