<?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>bluegold &#187; ssl</title>
	<atom:link href="http://blog.bluegold.me/tag/ssl/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bluegold.me</link>
	<description>OpenSolaris と MacBook で自宅ネットワークを構築するメモ</description>
	<lastBuildDate>Thu, 26 Aug 2010 14:38:53 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>nginx: SNI拡張を使ってVirtualHostでTLSを設定</title>
		<link>http://blog.bluegold.me/2010/02/nginx-server-name-indication-extension/</link>
		<comments>http://blog.bluegold.me/2010/02/nginx-server-name-indication-extension/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 14:36:17 +0000</pubDate>
		<dc:creator>bg</dc:creator>
				<category><![CDATA[技術]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[pki]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.bluegold.me/?p=376</guid>
		<description><![CDATA[OpenSSLのSNI拡張を利用して、TLS で VirtualHost の設定を行います。]]></description>
			<content:encoded><![CDATA[<p><a href="/2010/02/howto-build-64bit-nginx-with-ssl-support-on-opensolaris/">前回の記事</a>でSNI(Server Name Indication)拡張を有効にしたnginxのバイナリを作成したので遊んでみました。SNI拡張は、個々の仮想ホスト(VirtualHost)で独自のサーバ証明書を利用するために作られた TLSv1 の拡張仕様です。</p>
<p>TLSやSSLを使ったウェブサーバーでは一般的には仮想ホストは使えない、という事になっています（何事にも例外はありますが。）仮想ホストは HTTP のリクエストヘッダの Host フィールドの値を元に振り分けられますが，HTTPのリクエストを出すよりも手前の TLS/SSL のハンドシェイク時にサーバ証明書の検証が行われるので，クライアントが接続しようとしているホスト名とサーバ証明書のホスト名が異なってしまい，不正な証明書と表示されてしまいます。</p>
<p>SNIは接続しようとしているホスト名を、クライアントからサーバに伝えるための仕様です。（ホスト名はハンドシェイク前に伝えないと行けないので、平文で送られる事になりますが。。。）これ自体は素晴らしいのですが，Windows XP の IE がサポートしていないので今ひとつ広まっていません。</p>
<p><span id="more-376"></span></p>
<p>まずは SNI を使わないで仮想ホストを設定する場合の例です。</p>
<pre class="bq">
ssl_certificate server_cert.pem;
ssl_certificate_key server_cer.key;
server {
    port 443;
    ssl on;
    server_name host1.example.com;
}
server {
    port 443;
    ssl on;
    server_name host2.example.co.jp;
}
</pre>
<p>サーバ証明書は1枚しか指定できないので，server_cert.pem には host1.example.com と host2.exacmple.co.jp の双方が記述されている必要があります。ホストが同一のドメインに存在する場合はワイルドカード証明書を使う方法もありますが，例のようにドメインが異なる場合は双方のホスト名をCNもしくはsubjectAltNameに記述します。この方法では仮想ホストが増える場合は証明書を発行し直す必要があります。
</p>
<p>次に SNI を使う場合の例です。</p>
<pre class="bq">
server {
    port 443;
    ssl on;
    ssl_certificate host1.example.com.pem;
    ssl_certificate_key host1.example.com.key;
    server_name host1.example.com;
}
server {
    port 443;
    ssl on;
    server_name host2.example.co.jp;
    ssl_certificate host2.example.co.jp.pem;
    ssl_certificate_key host2.example.co.jp.key;
}
</pre>
<p>仮想ホスト毎に証明書が指定する事ができるようになります。
</p>
<p>実際に SNI をサポートしている Firefox などのブラウザでアクセスすると、それぞれ異なる証明書を持つ事が確認できます。</p>
<p>ただ、現在の nginx に固有の問題かもしれませんが，仮想ホスト毎にクライアント証明書による認証の有無を切り替えるのは出来ないみたいです。<em>ssl_verify_client off;</em>な設定の仮想ホストが１つでもあると，クライアント認証を行う仮想ホストに対してもクライアント証明書が送られません。</p>
<p>クライアント認証が必要ない仮想ホストに対しても<em>ssl_verify_client optional;</em>を指定すると大丈夫なようですが。（<a href="http://wiki.nginx.org/NginxHttpSslModule">Nginx の Wiki</a>の説明では<em>optional</em> ではなく、<em>ask</em>になっているので注意が必要です。）</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluegold.me/2010/02/nginx-server-name-indication-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSolarisで64bitのnginxをビルドする</title>
		<link>http://blog.bluegold.me/2010/02/howto-build-64bit-nginx-with-ssl-support-on-opensolaris/</link>
		<comments>http://blog.bluegold.me/2010/02/howto-build-64bit-nginx-with-ssl-support-on-opensolaris/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 09:05:29 +0000</pubDate>
		<dc:creator>bg</dc:creator>
				<category><![CDATA[OpenSolaris]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[メモ]]></category>

		<guid isPermaLink="false">http://blog.bluegold.me/?p=362</guid>
		<description><![CDATA[OpenSolaris 2009.06 で 64bit 版の nginx をビルドする手順]]></description>
			<content:encoded><![CDATA[<div class="content">
<p><a href="http://nginx.net/">nginx</a>の新しいバージョン(0.7.65)がリリースされていたので，バージョンアップしてみました。</p>
<p>しばらく前に見つかっていた<a href="http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-3555">SSLの脆弱製</a>の実験をやろうと、久しぶりに SSL を有効にしたバイナリを作ろうとしたのですが，オプションの設定の仕方を忘れていて苦労しました。また、忘れても大丈夫なようにメモ。</p>
<p>OpenSolaris 2009.06 に含まれるOpenSSLは 0.9.8a と古いので、現時点での最新バージョンである<a href="http://www.openssl.org/source/openssl-0.9.8l.tar.gz">openssl-0.9.8l</a>をダウンロードしてきて使いました。今回は<a href="http://en.wikipedia.org/wiki/Server_Name_Indication">SNI(Server Name Indication)</a>を有効にしたいので<strong>enable-tlsext</strong>オプションを渡しています。
</p>
<pre class="brush: bash;">
./config --prefix=/usr/local no-shared enable-tlsext
make
pfexec make install
</pre>
<p>これだけでもビルドは出来るのですが，OpenSolaris 2009.06 のデフォルトの GCC 3.2.3 ではなく新しい /usr/bin/gcc-4.3.2 を使いたいので，少し手を入れています。</p>
<pre class="brush: bash;">
export CC=/usr/bin/gcc-4.3.2
export CFLAGS='-DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -march=native -O3 -Wall -DL_ENDIAN -DMD32_REG_T=int -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM'
./Configure --prefix=/usr/local no-shared enable-tlsext solaris64-x86_64-gcc
make
pfexec make install
</pre>
<p><span id="more-362"></span></p>
<p><strong>export CC=/usr/bin/gcc-4.3.2</strong>した後に<em>config</em>スクリプトを実行すると，solaris64-x86_64-gcc-4.3.2 みたいな os:compiler になってエラーになってしまうんですよね。回避方法を探すのに手間取ってしまいました。
</p>
<p>次に nginx のビルドですが，普通に configure を実行すると 32bit のバイナリが出来てしまいますので、gcc に渡すオプションも configure に渡します。</p>
<pre class="brush: bash;">
./configure --prefix=/usr/local --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-cc=/usr/bin/gcc-4.3.2 --with-cc-opt='-m64 -march=native -O3 -I/usr/local/include ' --with-cpu-opt=amd64 --with-ld-opt='-m64 -L/usr/local/lib -L/usr/lib/amd64'
make
pfexec make install
</pre>
<p>ビルドした内容を確認</p>
<pre class="brush: bash;">
$ file /usr/local/sbin/nginx
/usr/local/sbin/nginx:  ELF 64-bit LSB executable AMD64 Version 1, dynamically linked, stripped

$ /usr/local/sbin/nginx -V
nginx version: nginx/0.7.65
built by gcc 4.3.2 (GCC)
TLS SNI support enabled
configure arguments: --prefix=/opt/local --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module --with-cc=/usr/bin/gcc-4.3.2 --with-cc-opt='-m64 -march=native -O3 -I/usr/local/include' --with-cpu-opt=amd64 --with-ld-opt='-m64 -L/usr/local/lib -L/usr/lib/amd64'
</pre>
<p>SNIも有効になっています</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bluegold.me/2010/02/howto-build-64bit-nginx-with-ssl-support-on-opensolaris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
