I solved ssl in my web site. There wasn’t left another site that i didn’t look at, no other document that i didn’t read. At last i brougth informations together that in pieces and the think that i discover was unbelievable. It is being really easy, to my surprise.
In my PC, there is Zend Core For Oracle working on MS Server 2003. In this version of Zend, Apache 2.2.4 is being installed with Zend. When glacing at Apache’s config file, you realize that with some changes, it can work like an Apache with SSL. Come to the point where did i understand this:
in …/Zend/Apache2/conf/httpd.conf file there is line exactly look like below:
#LoadModule ssl_module modules/mod_ssl.so
Lets create our ssl certificate step by step.
- We have to be sure that our site is working before we did our SSL settings. We can test this writing http://localhost/ or http://localhost:8080/ in our browser.
- We open …/Apache/conf/httpd.conf file with any editor, give the name which we like to Servername part. For example i gave www.example.com. Because we changed something in config file, we will restart our apache server, like we always do.
- After the installation of Zend there was openssl.exe over the …/Apache2/bin index. We have to put openssl.cnf file in same index. This file looks like SpeedDial in windows system. I found this file from a site where SSL installation was being told.
- Open the command prompt, we run three different command. Pay attention to the ‘example’ word in the commands that it is same word with my servername.
- openssl req -config openssl.cnf -new -out deneme.csr
In this command we will be asked some informations. First one is ‘pass phrase’. We can write any word for pass phrase. However we have to keep in mind this word because in forward steps, this word is going to be asked. After we will enter country, city, state, company, our servername, email and password. We can give any value to the password. - openssl rsa -in privkey.pem -out deneme.key
In this step, we will be asked to enter the value for pass phrase that we enter in the first step. - openssl x509 -in deneme.csr -out deneme.crt -req -signkey deneme.key -days 365
If everything went ok, we will see lines like below.
Loading ’screen’ into random state - done
Signature ok
subject=/C=TR/ST=Istanbul/L=Istanbul/O=XXX/OU=XXX/CN=www.example
.com/emailAddress=my@email.com
Getting Private key
- openssl req -config openssl.cnf -new -out deneme.csr
- Above sentences create .csr, .crt and .key files. If you look, this files are in the …/Apache/bin index. We copy example.crt and example.key files and paste them below the …/Apache/conf index.
- Openning httpd.conf file, remove the # symbol, lets make this line active.
#LoadModule ssl_module modules/mod_ssl.so
#Include conf/extra/httpd-ssl.conf
Lets make this line active, too . Save the file. - Open the httpd-ssl.conf file that is in …/Apache2/conf/extra index in our editor which we activate in the above sentence. Change the ServerName, DocumentRoot, SSLCertificateFile and SSLCertificateFileKey values to make them harmonious with our system, save the file.
- Restart apache server.
- Write https://localhost/. (If our apache works on port 80.)
If we reach our web site and see a yellow lock at the right bottom corner of our site, it means we did a good job.
P.S.: The .cer and .crt files are the same. You can use one instead of another. But whichever you have, you need a .key file to use them.
Kendi web sitemde sertifika işini hallettim. Girmediğim site, okumadığım döküman kalmadı nerdeyse. Sonuçta parça parça olan bilgilerin hepsini bir araya getirdim ve keşfettiğim şey inanılmazdı. Ne kadar da kolay oluyormuş, meğerse.
PC’ mde MS Server2003 üzerinde Zend Core For Oracle yüklü. Zend Core For Oracle ın bu sürümünde Apache 2.2.4 de Zend’le birlikte kuruluyor. Apache’ nin config dosyasına bakılınca bu dosyanın halihazırda sanki bir kaç değişiklikle SSL ‘e uyumlu hale geleceği anlaşılıyor. Bunu nerden anladığıma gelince:
…/Zend/Apache2/conf/httpd.conf dosyasında
#LoadModule ssl_module modules/mod_ssl.so
satırı var. Bu satırdan anladım.
Şimdi adım adım SSL sertifikamızı yaratalım.
- SSL ayarları yapılmadan önce sitemizin çalıştığından emin olalım. Tarayıcımıza http://localhost/ veya http://localhost:8080/ yazarak bunu test edebiliriz.
- …/Apache/conf/httpd.conf dosyasını herhangi bir editörle açıp, Servername kısmına istediğimiz bir isim verelim. Örneğin ben www.deneme.com gibi bir isim verdim. Config dosyasında değişiklik yaptığımız için, her zaman yaptığımız gibi apache serverımızı restart edeceğiz.
- …/Apache2/bin dizinin altında openssl.exe zaten kurulumdan sonra bulunuyordu. openssl.cnf dosyasını da bu dizinin altına koymalıyız. Bu dosya SpeedDial olarak görünüyor. Ben bu dosyayı SSL kurulumunu anlatan bir siteden bulmuştum.
- Komut satırını açıp, 3 ayrı komut çalıştıracağız. Dikkat edilecek aşağıdaki komutlarda geçen “deneme” kelimeleri benim sitemin ismiyle (www.deneme.com) aynı.
- openssl req -config openssl.cnf -new -out deneme.csr
Bu komutta bize bazı bilgiler sorulacak. Birincisi ‘pass phrase’. Pass phrase’ ın karşılığına herhangi bir kelime yazabiliriz. Yalnız yazdığımız kelimeyi aklımızda tutmalıyız çünkü ilerki adımlarda bize bu kelimeyi soracak. Ardından bize bulunduğumuz ülke, şehir, ilçe, şirket ismi, sitemizin adı, e-posta adresimiz ve şifre sorulacak. Şifreye de herhangi bir değer girebiliriz. - openssl rsa -in privkey.pem -out deneme.key
Bu adımda birinci adımda girdiğimiz pass phrase değerini girmemiz istenecek. - openssl x509 -in deneme.csr -out deneme.crt -req -signkey deneme.key -days 365
Eğer her şey düzgün gittiyse, ekranda aşağıdaki satırlara benzer satırlar göreceğiz.
Loading ’screen’ into random state - done
Signature ok
subject=/C=TR/ST=Istanbul/L=Istanbul/O=XXX/OU=XXX/CN=www.deneme
.com/emailAddress=my@email.com
Getting Private key
- openssl req -config openssl.cnf -new -out deneme.csr
- Yukarıdaki 3 komut bize gerekli olan .csr, .crt ve .key uzantılı dosyaları üretti. Eğer bakarsanız bu dosyalar …/Apache/bin dizininin altında bulunuyor. deneme.crt ve deneme.key dosyalarını alıp, …/Apache/conf dizinin altına kopyalayalım.
- httpd.conf dosyamızı açıp
#LoadModule ssl_module modules/mod_ssl.so
satırının başındaki # ifadesini kaldırıp, satırı aktif hale getirelim.
#Include conf/extra/httpd-ssl.conf
satırını da aktif hale getirelim. Dosyayı kaydedelim. - Bir önceki maddede aktif hale getirdiğimiz …/Apache2/conf/extra klasörünün içindeki httpd-ssl.conf dosyasını editörümüzde açalım. ServerName, DocumentRoot, SSLCertificateFile ve SSLCertificateFileKey bilgilerini sistemimize uygun hale getirip, dosyayı kaydedelim.
- Apache’ yi restart edelim.
- https://localhost/ yazalım. (Eğer apache serverımız 80 portunda çalışıyorsa tabii.)
Eğer web sayfamıza ulaşabiliyorsak ve web sayfamızın sağ alt köşesinde sarı bir kilit görüyorsak, ellerimize sağlık demektir.
