オレオレ証明書を作成する

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

オレオレ証明書についての詳細は、以下。

オレオレ証明書をオレ専用に使用する(オレ以外には使わない)分には、問題ないと思われる。たぶん。用途はクライアント認証。

作成するに辺り以下のサイトを特に参照させて頂いた。

以下にオレオレ証明書を作成した時の手順記述する。(FreeBSD-7.2)

% mkdir ssl-self-signed
% cd ssl-self-signed


■ オレオレ証明書用CA(認証局)の作成 (※ 県名等々は適当)
% /usr/src/crypto/openssl/apps/CA.pl -newca
CA certificate filename (or enter to create)

Making CA certificate …
Generating a 1024 bit RSA private key
…………………………………..++++++
……………………..++++++
writing new private key to ‘./demoCA/private/cakey.pem’
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:Kanagawa
Locality Name (eg, city) []:Kawasaki
Organization Name (eg, company) [Internet Widgits Pty Ltd]:foo bar Ltd
Organizational Unit Name (eg, section) []:System
Common Name (eg, YOUR name) []:qos.mine.nu-CA
Email Address []:root@qos.mine.nu

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
・・・
Write out database with 1 new entries
Data Base Updated

demoCAというディレクトリが出来ているはず。オレオレ証明書用CAの秘密鍵やら公開鍵やらもその中に作成される。


■ オレオレサーバ証明書の作成

% mkdir server-keys
% cd server-keys

● 秘密鍵を作成

% openssl genrsa -des3 -out secret.key 2048
Generating RSA private key, 2048 bit long modulus
…………………………………………………………+++
…………………………..+++
e is 65537 (0x10001)
Enter pass phrase for secret.key:
Verifying – Enter pass phrase for secret.key:
% openssl rsa -in secret.key -out secret-nopass.key
Enter pass phrase for secret.key:
writing RSA key

● CSR(Certificate Signing Request)作成

% openssl req -new -key secret.key -out csr.pem
Enter pass phrase for secret.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:Kanagawa
Locality Name (eg, city) []:Kawasaki
Organization Name (eg, company) [Internet Widgits Pty Ltd]:foo bar Ltd
Organizational Unit Name (eg, section) []:System
Common Name (eg, YOUR name) []:qos.mine.nu
Email Address []:root@qos.mine.nu

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

● オレオレCAで署名する

% cd ..
% cp /usr/src/crypto/openssl/apps/openssl.cnf .
% vi openssl.cnf
・・・
nsCertType          = server          ・・・コメントを外す
・・・
% openssl ca -in ./server-keys/csr.pem -out ./server-keys/server.cert -config ./openssl.cnf
Using configuration from ./openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
・・・
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Cert Type:
                SSL Server
            Netscape Comment:
                OpenSSL Generated Certificate
・・・
Sign the certificate? [y/n]:y
CERTIFICATE WILL NOT BE CERTIFIED

 


■ クライアント証明書の作成

% mkdir client-keys

● 秘密鍵を作成(クライアント証明書用)
% openssl genrsa -des3 -out secret.key 2048
Generating RSA private key, 2048 bit long modulus
……………+++
……………………….+++
e is 65537 (0x10001)
Enter pass phrase for secret.key:
Verifying – Enter pass phrase for secret.key:

● CSR(Certificate Signing Request)作成 (クライアント証明書用)

% openssl req -new -key secret.key -out csr.pem
Enter pass phrase for secret.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:JP
State or Province Name (full name) [Some-State]:Kanagawa
Locality Name (eg, city) []:Kawasaki
Organization Name (eg, company) [Internet Widgits Pty Ltd]:foo bar Ltd
Organizational Unit Name (eg, section) []:user
Common Name (eg, YO
UR name) []:user
Email Address []:user@qos.mine.nu

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

 

● オレオレCAで署名する (クライアント証明書用)
% cd ..
% vi openssl.cnf
・・・
# nsCertType          = server          ・・・コメントにする
nsCertType = client, email              ・・・コメントを外す
・・・

% openssl ca -in ./client-keys/csr.pem -out ./client-keys/client.cert -config ./openssl.cnf
Using configuration from ./openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
・・・
        X509v3 extensions:
            X509v3 Basic Constraints:
                CA:FALSE
            Netscape Cert Type:
                SSL Client, S/MIME
            Netscape Comment:
                OpenSSL Generated Certificate
・・・
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

● ブラウザにインポートしやすい形(秘密鍵と証明書のセット)にする

% cd client-keys
% openssl pkcs12 -export -in client.cert -inkey secret.key -out client.p12

出来たclient.p12をSCPとかで、クライアント端末に持ってきて、
ブラウザにインポートする。

サーバ証明書が見知らぬCAで署名されていると、「おまえ誰だよ?」的な感じで警告が出るので、オレオレ証明書用CAの証明書もブラウザにインポートする。demoCA/cacert.pem が、オレオレ証明書用CAの証明書なので、こいつもSCPとかでクライアント端末に持ってきて、インポート。


■ クライアント認証をするためのApache2の設定

辺りを設定する必要がある。

● 設定記述イメージ

Listen 443
NameVirtualHost *:443
<IfModule mod_ssl.c>
        <VirtualHost *:443>
            SSLEngine on
            SSLCertificateFile    /home/user/ssl-self-signed/server-keys/server.cert
            SSLCertificateKeyFile /home/user/ssl-self-signed/server-keys/secret-nopass.key
            SSLCACertificateFile /home/user/ssl-self-signed/demoCA/cacert.pem
            SSLVerifyClient require
・・・
            (他の設定)
        </VirtualHost>
</IfModule>

設定完了後、Apacheを再起動して、クライアント証明書をインポートしたブラウザでhttpsアクセス。証明書を要求され、インポートした証明書を選択することで正常にアクセスできたら成功。

Google ChromeはSSLクライアント認証をサポートしてないようなので、IEかFirefoxかOpera辺りで。

カテゴリー: サーバ管理 | タグ: , , , , , , | 1件のコメント

ファイル名をEUC-JPから、UTF-8に変更

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

玄箱のlocaleをEUC-JPから、UTF-8に変更したら日本語ファイルが文字化けてしまったので、変換する方法を探したところ、以下を発見。

ファイル名をEUC-JPやShift_JISからUTF-8へ変換する

①$sudo aptitude install convmv
②変換したいファイルがあるフォルダで以下のコマンドを実行する
  a)EUC-JPから変換する場合
    $ convmv -r -f euc-jp -t utf8 * –notest

convmv・・・こんな素敵なツールがあったとは。

localeを変更した理由は何となく。。

カテゴリー: ソフトウェア | タグ: | コメントする

SeagateのHDD

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

にバグがあって、HDDが応答しなくなるとかならないとかの話が、かなり前(2009年01月)にあったけど、そういえば自分のHDDをチェックしてなかった。。

今日現在動作している、Seagate製のHDDは、ST31500341AS、ST380815AS、ST31000333ASの3つ。

シリアル番号確認ユーティリティ(seagate)

で確認したところ何れも「No action required.」と。
ま、今更なんですけど。。。

以下、情報収集時に参照したサイト。

Seagate | ひねもす庵

スラッシュドット・ジャパン | Seagate製HDDの最新ファームウェアに新たな問題

カテゴリー: ハードウェア | タグ: , | コメントする

firefox 3が遅くなった→ SQLite reindexで解決&高速化 – しおそると

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

firefox 3が遅くなった→ SQLite reindexで解決&高速化 – しおそると

で、ふと思い立って Firefox 3 で利用している、SQLite データ群をかたっぱしから Reindex したら、
昔のスピードが再現しました。はやい!

改善:2つ
 1)起動が速くなった(起動に1-2分かかる→すぐ起動。劇的に改善。)
 2)サイト表示もはやい。 cookies などの処理がはやくなったため?

 

自動でReindexしてくれるアドオンもあるらしい。

Mozilla Re-Mix: Firefoxのデータベースを最適化して高速化を図るアドオン「SQLite Optimizer」

カテゴリー: その他 | タグ: | コメントする

FreeBSD 7.2-RELEASE

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

FreeBSD 7.2-RELEASE登場 – スラッシュドット・ジャパン

FreeBSD 7.2-RELEASE登場,安定ブランチの最新版 – Jail仮想化機能IPアドレス強化とスーパーページ改善|gihyo.jp … 技術評論社

FreeBSD 7.2-RELEASE Announcement

FreeBSD 7.2-RELEASE Announcement

The FreeBSD Release Engineering Team is pleased to announce the availability of FreeBSD 7.2-RELEASE. This is the third release from the 7-STABLE branch which improves on the functionality of FreeBSD 7.1 and introduces some new features. Some of the highlights:

  • support for fully transparent use of superpages for application memory

  • support for multiple IPv4 and IPv6 addresses for jails

  • csup(1) now supports CVSMode to fetch a complete CVS repository

  • Gnome updated to 2.26, KDE updated to 4.2.2

  • sparc64 now supports UltraSparc-III processors

For a complete list of new features and known problems, please see the online release notes and errata list, available at:

For more information about FreeBSD release engineering activities, please see:

・・・
FreeBSD Update

The freebsd-update(8) utility supports binary upgrades of i386 and amd64 systems running earlier FreeBSD releases. Systems running 7.0-RELEASE, 7.1-RELEASE, 7.2-BETA, 7.2-RC1, or 7.2-RC2 can upgrade as follows:

# freebsd-update upgrade -r 7.2-RELEASE

During this process, FreeBSD Update may ask the user to help by merging some configuration files or by confirming that the automatically performed merging was done correctly.

# freebsd-update install

The system must be rebooted with the newly installed kernel before continuing.

# shutdown -r now

After rebooting, freebsd-update needs to be run again to install the new userland components, and the system needs to be rebooted again:

# freebsd-update install
# shutdown -r now

Users of earlier FreeBSD releases (FreeBSD 6.x) can also use freebsd-update to upgrade to FreeBSD 7.2, but will be prompted to rebuild all third-party applications (e.g., anything installed from the ports tree) after the second invocation of “freebsd-update install”, in order to handle differences in the system libraries between FreeBSD 6.x and FreeBSD 7.x.
・・・

freebsd-updateユーティリティでバイナリアップグレードが可能らしい。
以下が詳しい。

FreeBSD 7.0 へようこそ:第3回 freebsd-updateで楽々リリースサーフィン|gihyo.jp

UNIXの部屋 コマンド検索:freebsd-update (*BSD/Linux)

On-line Manual of “freebsd-update”

 

遠隔地のサーバを、sshでアクセスして、サクッとUpgradeしてみることにした。
途中で失敗して立ち上がらなくなったりしたら、飛行機代があれだけど。。

% uname -r
7.1-RELEASE-p4

% freebsd-update –help

usage: freebsd-update [options] command … [path]

Options:
  -b basedir   — Operate on a system mounted at basedir
                  (default: /)
  -d workdir   — Store working files in workdir
                  (default: /var/db/freebsd-update/)
  -f conffile  — Read configuration options from conffile
                  (default: /etc/freebsd-update.conf)
  -k KEY       — Trust an RSA key with SHA256 hash of KEY
  -r release   — Target for upgrade (e.g., 6.2-RELEASE)
  -s server    — Server from which to fetch updates
                  (default: update.FreeBSD.org)
  -t address   — Mail output of cron command, if any, to address
                  (default: root)
Commands:
  fetch        — Fetch updates from server
  cron         — Sleep rand(3600) seconds, fetch updates, and send an
                  email if updates were found
  upgrade      — Fetch upgrades to FreeBSD version specified via -r option
  install      — Install downloaded updates or upgrades
  rollback     — Uninstall most recently installed updates
  IDS          — Compare the system against an index of “known good” files.

 

/var の容量が少ないので、-d /home/tmp/freebsd-updateとかにしておく。

% sudo freebsd-update upgrade -r 7.2-RELEASE -d /home/tmp/freebsd-update

Looking up update.FreeBSD.org mirrors… 6 mirrors found.
Fetching public key from update1.FreeBSD.org… done.
Fetching metadata signature for 7.1-RELEASE from update1.FreeBSD.org… done.
Fetching metadata index… done.
Fetching 2 metadata files… done.
Inspecting system… done.

The following components of FreeBSD seem to be installed:
kernel/generic src/base src/bin src/contrib src/crypto src/etc src/games
src/gnu src/include src/krb5 src/lib src/libexec src/release src/rescue
src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin
world/base world/dict world/doc world/games world/info world/manpages
world/proflibs

The following components of FreeBSD do not seem to be installed:
src/cddl world/catpages world/lib32

Does this look reasonable (y/n)? y

Fetching metadata signature for 7.2-RELEASE from update1.FreeBSD.org… done.
Fetching metadata index… done.
Fetching 1 metadata patches. done.
Applying metadata patches… done.
Fetching 1 metadata files… done.
Inspecting system… done.                        ← ここで多少時間掛かる
Fetching files from 7.1-RELEASE for merging… done.

Preparing to download files… done.           ← ここからがかなり長い
Fetching 30796 patches…..10….20….30….40….50….60….70….80….90….100….110….1

・・・

…30760….30770….30780….30790… done.
Applying patches… done.
Fetching 581 files… done.
Attempting to automatically merge changes in files… done.

The following file could not be merged automatically: /etc/mail/mailer.conf
Press Enter to edit this file in /usr/bin/vi and resolve the conflicts
manually…            ← 自動でマージ出来なかった場合(?)は、viが立ち上がって手動修正

この後、Updateで削除されるファイル、追加されるファイル、更新されるファイルの一覧が表示されて終了。

% sudo du -hs /home/tmp/freebsd-update
583M    /home/tmp/freebsd-update

と、それなりのサイズに。
次のコマンドで、実際にインストールされる。

% sudo freebsd-update install -d /home/tmp/freebsd-update

Installing updates…
Kernel updates have been installed.  Please reboot and run
“/usr/sbin/freebsd-update install” again to finish installing updates.

% sudo shutdown -r now

を叩いた後、1分ほど黙祷。その後、sshでログインしてみる。
ログインできたら、メッセージの通り再度、

% sudo freebsd-update install -d /home/tmp/freebsd-update
Installing updates… done.           ← そこそこ時間掛かる

でUpgrade完了。

% uname -r
7.2-RELEASE

ついでに、7.2-RELEASEが更新されたら通知してくれるよう、cronの設定もしておく。

% sudo vi /etc/crontab
0 3 * * * root /usr/sbin/freebsd-update cron -d /home/tmp/freebsd-update

を最終行に追加。

freebsd-update cron は、基本fetchと同じらしい。違いは、処理開始前に、1 ~ 3,600秒スリープすることと、結果をメールすることくらい。
man freebsd-update
に書いてある。
view /usr/sbin/freebsd-update
で、ソース見た方が早いかも。かなり見易く綺麗なソースだ。

カテゴリー: サーバ管理 | タグ: , , , | コメントする

C++テンプレートテクニック購入

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

(「C++テンプレートテクニック」もくじ)

テンプレートがどういう物か?くらいは知ってるけど、実装しようとした事は無い…。もちろん、string とか vector, set, map 辺りはよく使ってたけど。

・・・と、そんな理解度の人間ですが、「Chapter2 テンプレートの基礎ま」では、大半が知ってることだったのでスラスラ読めたけど、「Chapter3 Generic Programmingの基礎」のタグ・ディスパッチ辺りから、読むスピードが急激にDown。自分の脳みそじゃ、サンプルプログラム書きながらじゃないと無理って事は分かった。

まだ、4分の1も読んでないので、感想もクソも無いけど、「面白そう」ではある。

カテゴリー: その他 | タグ: , , , | コメントする

SVGは、imgタグで表示されない事を知る

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

いや、まぁ、それだけなんですけど。。HTML書いてて知った。
Internet Explorer8とFirefox3.0.10でダメだった。

  • iframeで表示させる
  • object(or embed)で埋め込む

のどっちかしか無いのかな。

UMLGraphを使うとき、SVGで吐くとキレイで良いんだけど、まだ扱い辛い模様。

カテゴリー: その他 | タグ: , , , | コメントする

Emacsを久しぶりに使ってみた

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

設定ファイルを少し修正する。とか、簡単なシェルスクリプトを作ってみる。くらいしか、エディタを使わないから、viで十分。だったんだけど、perlやらhtmlやらjavascriptやらをゴチャゴチャと弄っていると、ササッとバッファ切り替えたいとか、画面を分割したいとか思うようになったので、Emacsを使おうと決心した。(vim使うのも良いんだけど、やっぱEmacsなキーバインドは魅力。)

で、まずはインストールってことで、/usr/ports/editors 配下のMuleを探すも見つからず・・・。あれこれ情報を探してみたところ、↓の情報を発見。

GNU Emacs FAQ 日本語訳: Finding Emacs and related packages

8.5 Emacs と XEmacs (元 “Lucid Emacs”)の違いは? (2004/07/29)

まず第一に、どちらも GNU Emacs であることには変わりありません。 XEmacs は FSF の配布する Emacs と同程度に最新のバージョンです。この FAQ では FSF の配布しているものだけを “Emacs” と呼びます。その理由は一つには XEmacs の保守をしている人たちは彼らのプログラムを “XEmacs” と呼んで区別しているからで、一つには Emacs と XEmacs の違いを難解な用語や歴史に惑わされることなくうまく正確に説明することはできないからです。

XEmacs は Lucid Emacs として開発が始まりました。それは Emacs 19 の古いバージョンと Epoch をベースにしていました。 Epoch は Emacs 18 に X に対応した機能を組み込んだものです。

Emacs (つまり FSF の配布するバージョン)は様々なシステムにインストールできるようになっていて、現在では MULE (多言語対応)を含んでいます。
・・・

MuleはEmacsに取り込まれたそうな。へぇ~。

% sudo portinstall editors/emacs
・・・
% emacs –version
GNU Emacs 22.3.1
Copyright (C) 2008 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

% emacs

で、デフォルト設定のまま使ってみて不便だった点は、

  • C-h がBackspaceではない
  • 端末の背景色が黒だと、ミニバッファにフォーカスが有る場合の文字が見辛い。
  • javascript-modeがデフォルトで入ってない

ま、設定すりゃ良いんだけど。ってことで、設定した箇所が以下。
% cat ~/.emacs

(define-key global-map “\C-h” ‘delete-backward-char)

; デフォルトだとミニバッファの文字が見辛いので変更
(set-face-foreground ‘minibuffer-prompt “white”)
(set-face-background ‘minibuffer-prompt “black”)

; javascript-mode
; wget http://www.brgeight.se/downloads/emacs/javascript.el
(autoload ‘javascript-mode “javascript” nil t)

javascript-modeは、Phactory: debianにemacs javascript-modeをインストールするを参考にインストール。

う~ん、、、xyzzyのNetInstallerに該当するものが欲しい。。

追記 (2009/05/04)
右Altが効かないのが不便で色々調べていたら、Emacsではなくputtyの方だった・・・。
PuTTY 設定 → 端末 → キーボード にある、「右Altを右Altのまま使う(L)」をチェック。

参考:Puttyで右Altキーを有効にする – たぶん、駄文

カテゴリー: ソフトウェア | タグ: , , , | コメントする

UMLGraph(2)

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

出先で急にシーケンス図を出力したくなったとき用に、webからpic2plotへデータを食わせる簡易ツールを作ってみた。output_sequence.html

これで安心して外出できる。

カテゴリー: その他 | タグ: | コメントする

UMLGraphを使えば簡単にシーケンスが吐けるらしい

この記事は2年以上前に書いたものです。
そのため情報が古い可能性があります。ご了承ください。m(_ _)m

正確に言うと、UMLGraphに含まれるsequence.picというPICなフォーマットで書かれているマクロ集を使えば簡単にシーケンスが吐けると。

UMLGraph – Declarative Drawing of UML Diagrams

実際に、シーケンス図を吐き出すには、pic2plotってのを使うらしい。
pic2plotは、plotutilsに含まれている。

Index of /pub/GNU/plotutils

から最新のソースをダウンロードして、解凍後、cygwinで、

./configure –prefix=~/plotutils
make
make install

何故か、pic2plotがインストールされなかったので、個別に。

cd pic2plot
make
make install

cd ~/UMLGraph-5.2/lib
cat sample.pic

.PS
copy "./sequence.pic"
# Define the objects
object(O,"o:Toolkit");
placeholder_object(P);
step();
# Activation and messages
active(O);
message(O,O,"callbackLoop()");
create_message(O,P,"p:Peer");
message(O,P,"handleExpose()");
active(P);
return_message(P,O,"");
inactive(P);
destroy_message(O,P);
inactive(O);
# Complete the lifeline of O
step();
complete(O);
.PE

UMLGraph – Declarative Drawing of UML DiagramsのSequence Diagramsに書いてあるサンプルの前後に、
.PS

copy “./sequence.pic”

と
.PE
を追加しただけ。

早速、試し吐きを。

./plotutils/bin/pic2plot.exe -Tsvg sample.pic >! sample.svg
ls -alrt sample.svg
-rw-r–r– 1 Administrator なし 0 Apr 25 00:31 sample.svg

サイズが0?エラーでないけど失敗???
あれこれやってみた結果、どうも改行コードが影響してたっぽい。
CRLFだと何故かちゃんと吐いてくれない。LFに変更してから再度

./plotutils/bin/pic2plot.exe -Tsvg sample.pic >! sample.svg
ls -alrt sample.svg
-rw-r–r– 1 Administrator なし 6004 Apr 25 00:33 sample.svg

sample.svg

良い感じ。だけど、複雑なシーケンス図を書こうとすると結構大変そうな気もするなぁ。。。

カテゴリー: その他 | タグ: , , | コメントする