<?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>MacOSCoders &#187; Leopard</title>
	<atom:link href="http://www.macoscoders.com/category/leopard/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.macoscoders.com</link>
	<description>My blog to talk on iPhone, Mac OS, Adobe Flex, AIR...</description>
	<lastBuildDate>Mon, 16 Aug 2010 10:45:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Error: &#8220;CGGStackRestore: gstack underflow&#8221;</title>
		<link>http://www.macoscoders.com/2009/11/02/error-cggstackrestore-gstack-underflow/</link>
		<comments>http://www.macoscoders.com/2009/11/02/error-cggstackrestore-gstack-underflow/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 07:55:24 +0000</pubDate>
		<dc:creator>Anish Kumar</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[IPhone]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[XCode]]></category>
		<category><![CDATA[iPhone Applications]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[CGContextRestoreGState]]></category>
		<category><![CDATA[CGContextSaveGState]]></category>
		<category><![CDATA[CoreGraphics]]></category>

		<guid isPermaLink="false">http://www.macoscoders.com/?p=383</guid>
		<description><![CDATA[Today while I was working with some CoreGraphics API&#8217;s, I encountered a error which I was seeing it for the first time. CG for dumping an error &#8220;CGGStackRestore: gstack underflow&#8221; in the console everytime I invoked a method that was doing some CG based operations. Googling around I found that in CoreGraphics, you can save [...]]]></description>
			<content:encoded><![CDATA[<p>Today while I was working with some CoreGraphics API&#8217;s, I encountered a error which I was seeing it for the first time. CG for dumping an error &#8220;CGGStackRestore: gstack underflow&#8221; in the console everytime I invoked a method that was doing some CG based operations. Googling around I found that in CoreGraphics, you can save (CGContextSaveGState) and restore (CGContextRestoreGState) the graphics state. When the  state is saved, a copy is put on the graphics state&#8217;s &#8220;stack&#8221;, and when  it is restored, the top state on the stack is removed and used. If we  restore the state more times than we save it and then when we try to remove  and use the top item of the stack, the stack is empty, causing a stack  &#8220;underflow&#8221; error. So just make sure you have enough save-restore state methods called and it will fix the issue.</p>
<div class="wp-caption aligncenter" style="width: 765px"><img title="CGGStackRestore" src="http://www.macoscoders.com/images/CGGStackRestore.jpg" alt="CGGStackRestore" width="755" height="59" /><p class="wp-caption-text">CGGStackRestore</p></div>
<div id="wherego_related"> </div>]]></content:encoded>
			<wfw:commentRss>http://www.macoscoders.com/2009/11/02/error-cggstackrestore-gstack-underflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable HTTPS On Apache Running On A Leopard</title>
		<link>http://www.macoscoders.com/2009/07/22/enable-https-on-apache-running-on-a-leopard/</link>
		<comments>http://www.macoscoders.com/2009/07/22/enable-https-on-apache-running-on-a-leopard/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 12:22:42 +0000</pubDate>
		<dc:creator>Anish Kumar</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[RSA]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.macoscoders.com/?p=298</guid>
		<description><![CDATA[SSL is a big part of building secure web services. The steps outlined below can help generate a certificate for Adobe AIR applications to be signed.
Quick note: This is a fairly detailed process, so take a firm hold of the wheel and be prepared for a lengthy ride. You are going to need your terminal [...]]]></description>
			<content:encoded><![CDATA[<p>SSL is a big part of building secure web services. The steps outlined below can help generate a certificate for Adobe AIR applications to be signed.</p>
<p><strong>Quick note:</strong> This is a fairly detailed process, so take a firm hold of the wheel and be prepared for a lengthy ride. You are going to need your terminal and su access.<br />
You will be generating encryption keys and certificates, and editing Apache conf files.<br />
First, you need a certificate</p>
<p><strong>Step 1</strong></p>
<p>Open up a terminal window, and su root. Then, cd over to your Documents directory.</p>
<p>Add a new directory in there using mkdir and call it certs like so:</p>
<pre>sh-3.2# mkdir certs</pre>
<p>Then cd into it.</p>
<p>Type this command…</p>
<pre>sh-3.2# /System/Library/OpenSSL/misc/CA.pl -newca</pre>
<p>You’ll see a whole pile of stuff fly by, piece by piece:</p>
<pre>CA certificate filename (or enter to create) (hit enter)</pre>
<pre>Making CA certificate ...</pre>
<pre>Generating a 1024 bit RSA private key</pre>
<pre>......++++++</pre>
<pre>...........++++++</pre>
<pre>writing new private key to './demoCA/private/cakey.pem'</pre>
<pre>Enter PEM pass phrase: [enter a passphrase]</pre>
<pre>Verifying - Enter PEM pass phrase: [enter the passphrase again]</pre>
<pre>-----</pre>
<p>You are about to be asked to enter information that will be incorporated into your certificate request.<br />
What you are about to enter is what is called a Distinguished Name or a DN.<br />
There are quite a few fields but you can leave some blank<br />
For some fields there will be a default value, If you enter &#8216;.&#8217;, the field will be left blank.<br />
&#8212;&#8211;</p>
<p><span id="more-298"></span></p>
<pre>Country Name (2 letter code) [AU]: (hit enter)</pre>
<pre>State or Province Name (full name) [Some-State]: (hit enter)</pre>
<pre>Locality Name (eg, city) []: (hit enter)</pre>
<pre>Organization Name (eg, company) [Internet Widgits Pty Ltd]: (hit enter)</pre>
<pre>Organizational Unit Name (eg, section) []: (hit enter)</pre>
<pre>Common Name (eg, YOUR name) []: (type ‘yourname’)</pre>
<pre>Email Address []: (type ‘yourname@yourname.com’)</pre>
<p>You should now have a pile of directories and files that look like this:</p>
<address>~/Documents/certs/demoCA</address>
<address>~/Documents/certs/demoCA/cacert.pem</address>
<address>~/Documents/certs/demoCA/certs</address>
<address>~/Documents/certs/demoCA/crl</address>
<address>~/Documents/certs/demoCA/index.txt</address>
<address>~/Documents/certs/demoCA/newcerts</address>
<address>~/Documents/certs/demoCA/private</address>
<address>~/Documents/certs/demoCA/serial</address>
<p>Use ls to check. If so, good.</p>
<p><strong>Step 2</strong></p>
<p>Now you are going to generate a private key for your web server…stay in ~/certs and type…</p>
<pre>sh-3.2# openssl genrsa -des3 -out secureserver.key 1024</pre>
<p>A file should be created in ~/certs called secureserver.key, so you can choose any name you want but make it a good one – you’ll need to reference it later.<br />
This will pass the screen:</p>
<pre>Generating RSA private key, 1024 bit long modulus</pre>
<pre>...++++++</pre>
<pre>.......................................++++++</pre>
<pre>e is 65537 (0x10001)</pre>
<pre>Enter pass phrase for secureserver.key: (enter a passphrase)</pre>
<pre>Verifying - Enter pass phrase for secureserver.key: (enter the passphrase again)</pre>
<p><strong>Step 3</strong></p>
<p>Now we’ll create a non-password protected version of the same key:</p>
<pre>sh-3.2# openssl rsa -in secureserver.key -out secureserver.nopass.key</pre>
<p>The command will return this:</p>
<p>Enter pass phrase for secureserver.key: (enter the passphrase from step 2)<br />
writing RSA key</p>
<p>You should now have another file called secureserver.nopass.key (or whatever you decided for the ’secureserver’ name), in the ~/certs directory.</p>
<p><strong>Step 4</strong></p>
<p>Now we’ll create a certificate request, which should wind up as yet another file called newreq.pem. Stay in ~/certs, and…</p>
<pre>sh-3.2# openssl req -config /System/Library/OpenSSL/openssl.cnf -new -key secureserver.key -out newreq.pem -days 3650</pre>
<p>…and noting all that goes on one line before you hit enter.</p>
<p>This is creating a cert request good for ten years, using that key (secureserver.key) you created in step 2.</p>
<p>Output will look like so:</p>
<p>Enter pass phrase for secureserver.key: (enter the passphrase from step 2 again) You are about to be asked to enter information that will be incorporated into your certificate request.<br />
What you are about to enter is what is called a Distinguished Name or a DN.<br />
There are quite a few fields but you can leave some blank<br />
For some fields there will be a default value, If you enter &#8216;.&#8217;, the field will be left blank.<br />
&#8212;&#8211;</p>
<pre>Country Name (2 letter code) [AU]: (hit enter)</pre>
<pre>State or Province Name (full name) [Some-State]: (hit enter)</pre>
<pre>Locality Name (eg, city) []: (hit enter)</pre>
<pre>Organization Name (eg, company) [Internet Widgits Pty Ltd]: (hit enter)</pre>
<pre>Organizational Unit Name (eg, section) []: (hit enter)</pre>
<pre>Common Name (eg, YOUR name) []: (type ‘yourname’)</pre>
<pre>Email Address []: (type ‘yourname@yourname.com’)</pre>
<pre>Please enter the following 'extra' attributes</pre>
<pre>to be sent with your certificate request</pre>
<pre>A challenge password []: (leave it blank)</pre>
<pre>An optional company name []: (leave it blank)</pre>
<p>Check to make sure newreq.pem is in ~/certs, and then we’ll move on to signing that certificate request.</p>
<p><strong>Step 5</strong></p>
<p>Next, enter:</p>
<pre>sh-3.2# /System/Library/OpenSSL/misc/CA.pl -signreq</pre>
<p>Output…</p>
<pre>Using configuration from /System/Library/OpenSSL/openssl.cnf</pre>
<pre>Enter pass phrase for ./demoCA/private/cakey.pem: (enter a passphrase)</pre>
<pre>Check that the request matches the signature</pre>
<pre>Signature ok</pre>
<pre>Certificate Details:</pre>
<pre>Serial Number:</pre>
<pre>82:e1:99:21:c1:a8:de:66</pre>
<pre>Validity</pre>
<pre>Not Before: Mar 26 17:19:45 2009 GMT</pre>
<pre>Not After : Mar 26 17:19:45 2010 GMT</pre>
<pre>Subject:</pre>
<pre>countryName = AU</pre>
<pre>stateOrProvinceName = Some-State</pre>
<pre>organizationName = Internet Widgits Pty Ltd</pre>
<pre>commonName = yourname</pre>
<pre>emailAddress = yourname@yourname.com</pre>
<pre>X509v3 extensions:</pre>
<pre>X509v3 Basic Constraints:</pre>
<pre>CA:FALSE</pre>
<pre>Netscape Comment:</pre>
<pre>OpenSSL Generated Certificate</pre>
<pre>X509v3 Subject Key Identifier:</pre>
<pre>B4:DC:51:EA:17:29:DD:3C:34:EC:6D:37:02:9E:44:C0:FE:71:88:1F</pre>
<pre>X509v3 Authority Key Identifier:</pre>
<pre>keyid:19:B0:82:96:E8:2C:E9:DC:B0:9D:5F:77:DD:F6:EB:31:90:9F:1C:50</pre>
<pre>DirName:/C=AU/ST=Some-State/O=Internet Widgits Pty Ltd/CN=yourname/emailAddress=yourname@yourname.com</pre>
<pre>serial:82:E1:99:21:C1:A8:DE:65</pre>
<p>Certificate is to be certified until Mar 26 17:19:45 2010 GMT (365 days)<br />
Sign the certificate? [y/n]: (hit ‘y’ then enter)</p>
<p>1 out of 1 certificate requests certified, commit? [y/n] (hit ‘y’, then enter)<br />
Write out database with 1 new entries<br />
Data Base Updated<br />
Signed certificate is in newcert.pem</p>
<p>After signing, you should have all four files in the ~/certs directory…they are:</p>
<p>secureserver.key<br />
secureserver.nopass.key<br />
newreq.pem<br />
newcert.pem</p>
<p>Very nice. You can park those files anywhere you like, but I’d suggest moving the entire certs directory under ~/Library/WebServer.</p>
<p>Off to Apache</p>
<p>Thank goodness Apple decided to update the Apache server in Leopard – I was getting mighty tired of digging around for version 1.3 implementation instructions.</p>
<p>Apache 2.2 was a welcome upgrade.</p>
<p>Further, the configuration files in the base install are almost ready to go – you need to add/change about a dozen lines total.</p>
<p><strong>Step 6</strong></p>
<p>Mose on over to /private/etc/apache2/extra and open up the httpd-ssl.conf file<br />
(you’ll need to have admin access for editing – I do this stuff in Xcode while logged in as root, but that’s otherwise your call).<br />
Scroll down to ‘Server Certificate’ and make sure the following lines are commented out:</p>
<address>#SSLCertificateFile &#8220;/private/etc/apache2/server.crt&#8221;</address>
<address>#SSLCertificateFile &#8220;/private/etc/apache2/server-dsa.crt&#8221;</address>
<p>Then add this line:</p>
<address>SSLCertificateFile &#8220;/Library/WebServer/certs/newcert.pem&#8221;</address>
<p>In the next config group, ‘Server Private Key’, comment out…</p>
<address>#SSLCertificateKeyFile &#8220;/private/etc/apache2/server.key&#8221;</address>
<address>#SSLCertificateKeyFile &#8220;/private/etc/apache2/server-dsa.key&#8221;</address>
<p>…and add…</p>
<address>SSLCertificateKeyFile &#8220;/Library/WebServer/certs/secureserver.nopass.key&#8221;</address>
<p>Again, under ‘Certificate Authority (CA)’, comment out…</p>
<address>#SSLCACertificatePath &#8220;/private/etc/apache2/ssl.crt&#8221;</address>
<address>#SSLCACertificateFile &#8220;/private/etc/apache2/ssl.crt/ca-bundle.crt&#8221;</address>
<p>…then add:</p>
<address>SSLCACertificateFile &#8220;/Library/WebServer/certs/demoCA/cacert.pem&#8221;</address>
<p>And one last time, under ‘Certificate Revocation Lists (CRL)’ you’ll comment out…</p>
<address>#SSLCARevocationPath &#8220;/private/etc/apache2/ssl.crl&#8221;</address>
<address>#SSLCARevocationFile &#8220;/private/etc/apache2/ssl.crl/ca-bundle.crl&#8221;</address>
<p>…and add:</p>
<address>SSLCARevocationPath &#8220;/Library/WebServer/certs/demoCA/crl&#8221;</address>
<p>Save and close, boys and girls, because you are almost home.</p>
<p><strong>Step 7</strong></p>
<p>Open up the httpd.conf file under /private/etc/apache2,</p>
<p>then scroll all the way to the bottom where it says ‘Secure (SSL/TLS) connections’ and UNCOMMENT this line:</p>
<address>Include /private/etc/apache2/extra/httpd-ssl.conf</address>
<p>Now, the stock httpd.conf file should have the line that says…</p>
<address>LoadModule ssl_module libexec/apache2/mod_ssl.so</address>
<p>…already uncommented, but if there is a # in front of it take it out. Everything else in the Apache config file should be kosher.</p>
<p><strong>Step</strong> 8</p>
<p>If you’ve gotten this far, you are probably going to want to do some editing to your hosts file, so you are hitting the URL locally.<br />
But, if you gotten this far you probably don’t need me to tell you how to do that either.</p>
<p>Restart your web server, and pour yourself a nice stiff cocktail.</p>
<div id="wherego_related"><h3>Readers who viewed this page, also viewed:</h3><ul><li><a href="http://www.macoscoders.com/2009/05/17/iphone-apple-push-notification-service-apns/" rel="bookmark" class="wherego_title">iPhone Apple Push Notification Service (APNS)</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/where-did-they-go-from-here/">Where did they go from here?</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.macoscoders.com/2009/07/22/enable-https-on-apache-running-on-a-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
