<?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>Chaos Engine &#187; Security</title>
	<atom:link href="http://dev.modmancer.com/index.php/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.modmancer.com</link>
	<description>Sometimes I drink to forget.. but then I forget to drink..</description>
	<lastBuildDate>Mon, 06 Feb 2012 16:11:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP and OpenSSL key format (&#8220;key parameter is not a valid public key&#8221;)</title>
		<link>http://dev.modmancer.com/index.php/2010/07/07/php-and-openssl-key-format/</link>
		<comments>http://dev.modmancer.com/index.php/2010/07/07/php-and-openssl-key-format/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 22:27:34 +0000</pubDate>
		<dc:creator>akiko</dc:creator>
				<category><![CDATA[OpenSSL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[openssl_pkey_get_public error]]></category>
		<category><![CDATA[private key]]></category>
		<category><![CDATA[public key]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://dev.modmancer.com/?p=73</guid>
		<description><![CDATA[PHP Warning: openssl_public_encrypt(): key parameter is not a valid public key in /script.php on line 175 If you experienced problems with OpenSSL and PHP, especially functions like openssl_pkey_get_public and openssl_pkey_get_private not willing to initialise from the provided public and private key strings, then you just need a few tweaks to get things running, because the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="color: #ff0000;">PHP Warning:  openssl_public_encrypt(): key parameter is not a valid public key in /script.php on line 175</span></strong></p>
<p>If you experienced problems with OpenSSL and PHP, especially functions like openssl_pkey_get_public and openssl_pkey_get_private not willing to initialise from the provided public and private key strings, then you just need a few tweaks to get things running, because the key formats are not compatible. If you are used to using ssh-keygen command line tool to generate your key pair, you will need to manually edit the public key in order to make it php openssl compatible. <span id="more-73"></span>For example your tmp_rsa.pub key looks like this:</p>
<pre>ssh-rsa ABABB3NzaC1yc2EAAAABIwAAAQEAtO9f1rn1plAH5flOotX0NYFjfQH7xt0dukt7v
8Nt3g7GFijXsoc+/+1SNSusHbj4LfBPXgKQJJoaZaCoQIWjBIXXKlODv+z2pSMBvvCPRThSFetqeh
/0pWcdiHPsmPOYpHby7zzwNKPCDyMrVrlC7FsaGmOC+F7FvSGA1PLdYEiOiJV/OmxQ
2HELrmhYPDc0vVPHfOETygNjjqMUuu8QwLvBgk3OUbT1m5NRNHMnpgPOID6+BBumLs
M0t8jOp1/AQG3pQFtlLBNETOMe7nuBPuE5pPhr5HbyV+9FUGI2FiYlNl7G+d8VlibR2wZkGHsa
p6mmzmJi64x4gNDdil+QDa== xyz@computer
</pre>
<p>That&#8217;s good for shell but not good enough for PHP openssl_pkey_get_public() function. You will need to manually edit it, and in the end it should look like this:</p>
<pre>-----BEGIN PUBLIC KEY-----
ABABB3NzaC1yc2EAAAABIwAAAQEAtO9f1rn1plAH5flOotX0NYFjfQH7xt0dukt7v
8Nt3g7GFijXsoc+/+1SNSusHbj4LfBPXgKQJJoaZaCoQIWjBIXXKlODv+z2pSMBvvC
PRThSFetqeh/0pWcdiHPsmPOYpHby7zzwNKPCDyMrVrlC7FsaGmOC+F7FvSGA1
PLdYEiOiJV/OmxQ2HELrmhYPDc0vVPHfOETygNjjqMUuu8QwLvBgk3OUbT1m5N
RNHMnpgPOID6+BBumLsM0t8jOp1/AQG3pQFtlLBNETOMe7nuBPuE5pPhr5HbyV
+9FUGI2FiYlNl7G+d8VlibR2wZkGHsap6mmzmJi64x4gNDdil+QDa==
-----END PUBLIC KEY-----
</pre>
<p>Don&#8217;t ask me why, it simply won&#8217;t work (or at least in my case didn&#8217;t work) if you don&#8217;t do it. It will still be complaining about some start line:</p>
<pre>error:0906D06C:PEM routines:PEM_read_bio:no start line
</pre>
<p>But that is obviously a trivial error, which you can ignore. I haven&#8217;t figured out yet how to avoid it.</p>
<p><strong>Another thing -</strong><br />
make sure you check for ssl errors after each ssl function. Here is a simple fn which can be helpful in your openSSL wrapper class:</p>
<pre>//! Checks for recent OpenSSL errors, and logs them.
//! \return true if no errors found, otherwise false.
public static function check_ssl_error()
{
  $ret = true;
  while ($msg = openssl_error_string())
  {
    // --- todo : log the error in your log file
    $ret = false;
  }
  return $ret;
}
</pre>
<p>So in the end you will init your openssl wrapper like this:</p>
<pre>$public_key_str = file_get_contents("./public.key");
$private_key_str = file_get_contents("./private.key");

MY_ASSERT($public_key_str, "Public key not found.");
MY_ASSERT($private_key_str, "Private key not found.");

$this-&gt;public_key = openssl_pkey_get_public($public_key_str);
OpenSSLWrapper::check_ssl_error();
OpenSSLWrapper::check_ssl_error();
$this-&gt;private_key = openssl_pkey_get_private($private_key_str);
OpenSSLWrapper::check_ssl_error();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dev.modmancer.com/index.php/2010/07/07/php-and-openssl-key-format/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Syncing Firefox bookmarks and passwords</title>
		<link>http://dev.modmancer.com/index.php/2010/05/23/syncing-firefox-bookmarks-and-passwords/</link>
		<comments>http://dev.modmancer.com/index.php/2010/05/23/syncing-firefox-bookmarks-and-passwords/#comments</comments>
		<pubDate>Sun, 23 May 2010 12:11:10 +0000</pubDate>
		<dc:creator>riddler</dc:creator>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[WebDAV]]></category>

		<guid isPermaLink="false">http://dev.modmancer.com/?p=46</guid>
		<description><![CDATA[I use a few computers and I like to have pretty much the same $ENV on them. Using various rsync methods helps keeping $HOME synced. Yet, sometimes that $HOME is way too big for syncing via the Internet. And what if I&#8217;d like to sync just some programes and not the whole damn $HOME dir? [...]]]></description>
			<content:encoded><![CDATA[<p>I use a few computers and I like to have pretty much the same $ENV on  them. Using various rsync methods helps keeping $HOME synced. Yet,  sometimes that $HOME is way too big for syncing via the Internet. And  what if I&#8217;d like to sync just some programes and not the whole damn  $HOME dir?<br />
<span id="more-46"></span></p>
<p>One of the things that was bothering me a lot was syncing Firefox and  it&#8217;s bookmarks/passwords on different computers. Especially when I  change a computer and forget to pickup whatever I needed on a USB  stick(encrypted one). And I need my bookmarks. I&#8217;m one of those geeks  who have been keeping a well organized bookmarks for the past 10+ years.  I&#8217;ve been digging around a bit and found a perfect solution. It comes  down to this: <a title="Lighty" href="http://www.lighttpd.net" target="_blank">Lighttpd</a> via <a title="WebDAV" href="http://en.wikipedia.org/wiki/WebDAV" target="_blank">WebDAV</a> and HTTPS and one neat plugin for Firefox.</p>
<p>This short HOWTO assumes that you know your way around with Lighty. I  won&#8217;t go too deep into details but if you need some additional help  just let me know. So, you&#8217;ll need Lighttpd compiled with WebDAV support.  Once that is done you need the following in your lighttpd.conf:</p>
<pre>$HTTP["host"] == "sync.com" {
server.document-root = "/home/user/sync"
server.errorlog      = "/var/log/sync.error.log"
accesslog.filename   = "/var/log//sync.access.log"
webdav.activate = "enable"
webdav.is-readonly = "disable"
}
</pre>
<p>This will allow you to read and write data to /home/user/sync which  will be our central location for keeping bookmarks and/or passwords. I  suggest using this location only via HTTPS.</p>
<p>Give settings will allow anyone rw access. Not a good idea. Add  something like this to your Lighttpd configuration:</p>
<pre>$HTTP["host"] =~ "sync.com" {
auth.require = ("/" =&gt; (
"method"  =&gt; "digest",
"realm"   =&gt; "Datasphere entrance",
"require" =&gt; "user=username"
))
}
</pre>
<p>Or tweak this password protection in any other way available for  Lighty &#8211;&gt; <a title="ModAuth" href="http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth" target="_blank">http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModAuth</a></p>
<p>We&#8217;re almost done.</p>
<p>Next step is to install Syncplaces addon for Firefox.You can find it  here: <a href="https://addons.mozilla.org/en-US/firefox/addon/8426" target="_blank">https://addons.mozilla.org/en-US/firefox/addon/8426</a></p>
<p>It&#8217;s pretty easy to setup. There are just a few things you need to  change in the Options menu: Host should be whatever is the hostname of  your sync site and paths to files for passwords and bookmarks. By  default those are /syncplaces.xml, /syncplaces.html and /passwords.  Change them to whatever you want. Syncplaces can be tweaked to do  automatic syncing at whatever time you like. Or when you shut down  Firefox thus making sure that the latest bookmarks and passwords will be  on server once you go an pull the data from another computer.</p>
<p>I&#8217;ve tried to keep this HOWTO as simple as possible. If any part of  it is not clear enough let me know and I&#8217;ll explain.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.modmancer.com/index.php/2010/05/23/syncing-firefox-bookmarks-and-passwords/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lighttpd and (network.c.529) SSL error</title>
		<link>http://dev.modmancer.com/index.php/2010/05/23/lighttpd-and-network-c-529-ssl-error/</link>
		<comments>http://dev.modmancer.com/index.php/2010/05/23/lighttpd-and-network-c-529-ssl-error/#comments</comments>
		<pubDate>Sun, 23 May 2010 12:05:11 +0000</pubDate>
		<dc:creator>riddler</dc:creator>
				<category><![CDATA[BSD]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://dev.modmancer.com/?p=42</guid>
		<description><![CDATA[I just realized that the latest Lighttpd you may find in FreeBSD ports (and in all Linux distros actually) is a bit buggy. Apparently there is an error in network.c which will crash your HTTPS. Once you upgrade and restart Lighty you&#8217;ll get something like this: 2010-03-05 10:23:01: (network.c.529) SSL: error:00000000:lib(0):func(0):reason(0) And that&#8217;s it. Lighty [...]]]></description>
			<content:encoded><![CDATA[<p>I just realized that the latest <a title="Lighttpd" href="http://www.lighttpd.net" target="_blank">Lighttpd</a> you may find in FreeBSD ports (and in all  Linux distros actually) is a bit buggy. Apparently there is an error in  network.c which will crash your HTTPS.<br />
<span id="more-42"></span><br />
Once you upgrade and restart  Lighty you&#8217;ll get something like this:</p>
<pre>2010-03-05 10:23:01: (network.c.529) SSL: error:00000000:lib(0):func(0):reason(0)</pre>
<p>And that&#8217;s it. Lighty will die. Well, here is a quick fix till new  port is released:</p>
<pre>cd /usr/ports/www/lighttpd
make install clean then Ctrl + C when it starts configuring
cd work/lighttpd-1..26/src/
rm network.c
fetch http://redmine.lighttpd.net/projects/lighttpd/repository/revisions/2716/
raw/branches/lighttpd-1.4.x/src/network.c
cd ../../ &amp;&amp; make install clean
</pre>
<p>And that&#8217;s it. It will fix the issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.modmancer.com/index.php/2010/05/23/lighttpd-and-network-c-529-ssl-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

