<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Georgi Mitev &#124; Learn Scripts Tutorials &#124; PHP Cron Mysql Flash &#187; ssl</title>
	<atom:link href="http://georgi-mitev.com/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>http://georgi-mitev.com</link>
	<description>Georgi Mitev&#039;s blog for scripts tutorials and something else</description>
	<lastBuildDate>Thu, 29 Apr 2010 09:00:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTTP, HTTPS, and SSL via PHP</title>
		<link>http://georgi-mitev.com/2009/05/10/http-https-and-ssl-via-php/</link>
		<comments>http://georgi-mitev.com/2009/05/10/http-https-and-ssl-via-php/#comments</comments>
		<pubDate>Sun, 10 May 2009 07:08:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[https and php]]></category>
		<category><![CDATA[https via php]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[sockets]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[ssl and php]]></category>
		<category><![CDATA[ssl via php]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=81</guid>
		<description><![CDATA[Today i found this very cool tutorial regarding the using of using ssl with PHP.
I&#8217;ll copy here the most interesting of it.
HTTP with PHP Sockets
// don&#8217;t need to specify http, it&#8217;s the default protocol
$hostname = &#8220;www.google.com&#8221;;
$port     = 80;
// create and configure the client socket
$fp = fsockopen($hostname, $port); // optional: $error_number, $error_string, [...]]]></description>
			<content:encoded><![CDATA[<p>Today i found this very cool tutorial regarding the using of using ssl with PHP.</p>
<p>I&#8217;ll copy here the most interesting of it.</p>
<h2><a name="http-sockets">HTTP with PHP Sockets</a></h2>
<p>// don&#8217;t need to specify http, it&#8217;s the default protocol<br />
$hostname = &#8220;www.google.com&#8221;;<br />
$port     = 80;</p>
<p>// create and configure the client socket<br />
$fp = fsockopen($hostname, $port); // optional: $error_number, $error_string, $connect_timeout<br />
if ($fp) {<br />
    stream_set_timeout($fp, 30); // seconds to wait for i/o operations</p>
<p>    // send request headers<br />
    fwrite($fp, &#8220;GET / HTTP/1.1\r\n&#8221;);<br />
    fwrite($fp, &#8220;Host: $hostname\r\n&#8221;);<br />
    fwrite($fp, $additional_headers); // Accept, User-Agent, Referer, etc.<br />
    fwrite($fp, &#8220;Connection: close\r\n&#8221;);</p>
<p>    // read response<br />
	$response = &#8220;&#8221;;<br />
    while (!feof($fp)) {<br />
        $response .= fgets($fp, 128);<br />
    }<br />
	echo $response;</p>
<p>    // close the socket<br />
    fclose($fp);<br />
}<br />
<span id="more-81"></span></p>
<h2><a name="raw-ssl-sockets">Direct SSL Sockets in PHP</a></h2>
<p>You don&#8217;t have to send request headers in the above example. You can actually connect to some servers and send raw text with <code>fwrite</code>. Because you have to implement the HTTP/HTTPS protocol yourself if you want it, sockets are considered &#8220;clean&#8221; connections.<br />
You don&#8217;t have to send request headers in the above example. You can actually connect to some servers and send raw text with fwrite. Because you have to implement the HTTP/HTTPS protocol yourself if you want it, sockets are considered &#8220;clean&#8221; connections.</p>
<p>// note that &#8220;ssl&#8221; is the protocol, NOT &#8220;https&#8221;<br />
$hostname  = &#8220;ssl://your-secure-site.com&#8221;;<br />
$port      = 443;</p>
<p>// create and configure the client socket<br />
$fp = fsockopen($hostname, $port);<br />
if ($fp) {<br />
    stream_set_timeout($fp, 30);</p>
<p>	// send data (or build HTTPS headers similar to first example)<br />
	fwrite($fp, &#8220;your message goes here&#8221;);</p>
<p>    // read response<br />
    while (!feof($fp)) {<br />
        echo fgets($fp, 128);<br />
    }</p>
<p>    // close the socket<br />
    fclose($fp);<br />
}</p>
<h2><a name="https-curl">HTTPS via cURL</a></h2>
<p>PHP doesn&#8217;t directly support attaching client certificates to web requests with <code>fsockopen</code>, so  you have to use the <code>cURL</code> library.<br />
$url = &#8220;https://your-secure-site.com/secure-service.php&#8221;;<br />
$port = 443;</p>
<p>// POST data, formatted just like a GET query string<br />
$request = &#8220;name=hb&amp;age=27&amp;site=arguments.callee.info&#8221;;</p>
<p>// the client certificate path MUST be a physical path, not url<br />
$certificate = &#8220;C:\\certificates\\test.crt&#8221;; // windows example<br />
$certificate = &#8220;/etc/pki/tls/private/test.crt&#8221;; // unix/linux example<br />
$password = &#8216;mypassword&#8217;; // client certificate&#8217;s key</p>
<p>// more details at http://php.net/curl<br />
$ch = curl_init();<br />
curl_setopt($ch, CURLOPT_POST, 1);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
curl_setopt($ch, CURLOPT_URL, $url);<br />
curl_setopt($ch, CURLOPT_PORT, $port);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);<br />
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);<br />
curl_setopt($ch, CURLOPT_SSLCERT, $certificate);<br />
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $password);</p>
<p>// fetch response and close the socket<br />
$response = curl_exec($ch);<br />
curl_close($ch);</p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/05/10/http-https-and-ssl-via-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Get your freak on with SSL and Apache :P</title>
		<link>http://georgi-mitev.com/2009/03/08/38/</link>
		<comments>http://georgi-mitev.com/2009/03/08/38/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 20:14:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web Developing]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[open ssl]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://georgi-mitev.com/?p=38</guid>
		<description><![CDATA[for everybody who is just starting to learn about the SSL оpportunities that you have with Open SSL (tool) and the mod_ssl for Apache for securing your site. The simplest and fastest thing that you can do is to create a self-signed certificate, after you generate a free RSA key  . Don&#8217;t worry it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>for everybody who is just starting to learn about the SSL оpportunities that you have with Open SSL (tool) and the mod_ssl for Apache for securing your site. The simplest and fastest thing that you can do is to create a self-signed certificate, after you generate a free RSA key <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Don&#8217;t worry it&#8217;s not so sophisticated as it sounds <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  actually it&#8217;s pretty easy. You can read more on the link below<br />
<a rel="lightbox" href="http://georgi-mitev.com/images/posts/3.2009/ssl.jpg"><img src="http://georgi-mitev.com/images/posts/3.2009/ssl.jpg" alt="ssl graph" width="60%" height="60%" /></a></p>
<p>Securing an Apache 2 Web server can be an intimidating prospect for those new to secure sockets layer (SSL) certificates. However, this need not be the case. SSL secures Web server to Web browser connections. Read on to better understand SSL certificates, learn how to set them up on Apache and launch your SSL-enabled site.</p>
<p><span id="more-38"></span>basically i will save you some of reading the long tutorial and will get straight to the point &#8211; here are some useful commands that you are going to learn from this tutorial. I had some problem with these commands under windows so i give you my updated version &#8211; everything should be ok here <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>i tested that with win7 and xampp 1.7 <img src='http://georgi-mitev.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>create RSA private key<br />
openssl genrsa -out mykey.pem 1024</p>
<p>create self-signed certificate<br />
openssl req -config &#8220;xammp-dir\apache\bin\openssl.cnf&#8221; -new -key my.key -x509 -out sslname.crt</p>
<p>create certificate signing request<br />
openssl req -new -key my.key -config &#8220;xammp-dir\apache\bin\openssl.cnf&#8221; -out my.csr</p>
<p>&lt;IfDefine HAVE_SSL&gt;</p>
<p>&lt;VirtualHost 10.0.0.5:443&gt;<br />
DocumentRoot /home/sites/domainname.com/html<br />
ServerName www.domainname.com<br />
ServerAlias domainname.com<br />
ServerAdmin admin@domainname.com<br />
ErrorLog /home/sites/domainname.com/logs/error_log<br />
TransferLog / home/sites/domainname.com/logs/access_log<br />
SSLEngine on<br />
SSLCertificateFile /etc/httpd/conf/ssl.crt/domainname.com.crt<br />
SSLCertificateKeyFile /etc/httpd/conf/ssl.key/domainname.com.key<br />
SetEnvIf User-Agent &#8220;.*MSIE.*&#8221; nokeepalive ssl-unclean-shutdown<br />
&lt;/VirtualHost&gt;</p>
<p>&lt;/IfDefine&gt;</p>
<p>you can read more here:<br />
<a href="http://www.sitepoint.com/article/securing-apache-2-server-ssl/">http://www.sitepoint.com/article/securing-apache-2-server-ssl/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://georgi-mitev.com/2009/03/08/38/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
