SSL作成方法

  • 一般的なSSLの作成方法を記載します。
  • SHA-2の発行方法です。

OpenSSLのバージョン確認

  • ターミナルで下記コマンドを実行します。
# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

秘密鍵の作成

# mkdir /etc/httpd/ssl/
# cd /etc/httpd/ssl/
# openssl genrsa -des3 -out コモンネーム.key 2048

CSR発行

  • -sha256オプションを入れるとSHA-2形式のCSRを発行できます。
  • ※SHA-2形式だとガラケーが対応できないので注意。

CSR発行コマンド

# openssl req -new -sha256 -key コモンネーム.key -out コモンネーム.csr

証明書のインストール

証明書

  • 発行された証明書をコピーして、vimで設置する
# vim /etc/httpd/ssl/コモンネーム.crt
証明書貼り付け

中間証明書

  • 発行された証明書をコピーして、vimで設置する
# vim /etc/httpd/ssl/コモンネーム.cer
証明書貼り付け

mod_sslのインストール

# yum install mod_ssl

VirtualHost設定

# vim /etc/httpd/conf.d/ssl.conf

  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
  ErrorLog logs/ssl_error_log
  TransferLog logs/ssl_access_log
  LogLevel warn

  SSLEngine on
  SSLProtocol All -SSLv2 -SSLv3
  SSLCipherSuite AES128+EECDH:AES128+EDH
  SSLHonorCipherOrder on
  Header add Strict-Transport-Security "max-age=15768000"

  BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

  CustomLog logs/ssl_admin_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

  SSLCertificateChainFile /etc/httpd/ssl/コモンネーム.cer
  SSLCertificateFile /etc/httpd/ssl/コモンネーム.crt
  SSLCertificateKeyFile /etc/httpd/ssl/コモンネーム.key
  ServerName ドメイン:443
  DocumentRoot "/var/www/html"
  
    Options All
    AllowOverride All
    Require all granted
  


# Virtual Host外に下記を記述
SSLCompression off

秘密鍵パスフレーズの解除

  • 必ず最初に作成した秘密鍵はコピーしてバックアップしておいてください。
# cp コモンネーム.key コモンネーム.key.org
# openssl rsa -in コモンネーム.key -out コモンネーム.key
# openssl rsa -text -noout -in /etc/httpd/ssl/コモンネーム.key

Apache再起動

  • ※設定ファイルの確認は必ずおこなってください。
# apachectl configtest
# apachectl reload

証明書確認ツール

SSL作成方法

SSL作成方法(Apache2)

Introduction

  • 一般的なSSLの作成方法を記載します。
  • SHA-2の発行方法です。

OpenSSLのバージョン確認

  • ターミナルで下記コマンドを実行します。
# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

秘密鍵の作成

# mkdir /etc/httpd/ssl/
# cd /etc/httpd/ssl/
# openssl genrsa -des3 -out コモンネーム.key 2048

CSR発行

  • -sha256オプションを入れるとSHA-2形式のCSRを発行できます。
  • ※SHA-2形式だとガラケーが対応できないので注意。

CSR発行コマンド

# openssl req -new -sha256 -key コモンネーム.key -out コモンネーム.csr

証明書のインストール

証明書

  • 発行された証明書をコピーして、vimで設置する
# vim /etc/httpd/ssl/コモンネーム.crt
証明書貼り付け

中間証明書

  • 発行された証明書をコピーして、vimで設置する
# vim /etc/httpd/ssl/コモンネーム.cer
証明書貼り付け

mod_sslのインストール

# yum install mod_ssl

VirtualHost設定

# vim /etc/httpd/conf.d/ssl.conf

  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
  ErrorLog logs/ssl_error_log
  TransferLog logs/ssl_access_log
  LogLevel warn

  SSLEngine on
  SSLProtocol All -SSLv2 -SSLv3
  SSLCipherSuite AES128+EECDH:AES128+EDH
  SSLHonorCipherOrder on
  Header add Strict-Transport-Security "max-age=15768000"

  BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

  CustomLog logs/ssl_admin_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

  SSLCertificateChainFile /etc/httpd/ssl/コモンネーム.cer
  SSLCertificateFile /etc/httpd/ssl/コモンネーム.crt
  SSLCertificateKeyFile /etc/httpd/ssl/コモンネーム.key
  ServerName ドメイン:443
  DocumentRoot "/var/www/html"
  
    Options All
    AllowOverride All
    Require all granted
  


# Virtual Host外に下記を記述
SSLCompression off

秘密鍵パスフレーズの解除

  • 必ず最初に作成した秘密鍵はコピーしてバックアップしておいてください。
# cp コモンネーム.key コモンネーム.key.org
# openssl rsa -in コモンネーム.key -out コモンネーム.key
# openssl rsa -text -noout -in /etc/httpd/ssl/コモンネーム.key

Apache再起動

  • ※設定ファイルの確認は必ずおこなってください。
# apachectl configtest
# apachectl reload

証明書確認ツール

apatch vhosts

vim /etc/httpd/vhost/~.com.conf

```

<VirtualHost *:80>
  DocumentRoot "/home/vhosts/www/htdocs/"
  ServerName www.domain.com
  ErrorLog "/home/vhosts/www/logs/error.log"
  <Directory "/home/vhosts/www/htdocs/">
    Options FollowSymLinks IncludesNoExec
    AllowOverride All
    Deny from none
  </Directory>
</VirtualHost>
<VirtualHost *:80>
  DocumentRoot "/home/vhosts/dev/htdocs/"
  ServerName dev.domain.com
  ErrorLog "/home/vhosts/dev/logs/error.log"
  <Directory "/home/vhosts/dev/htdocs/">
    Options FollowSymLinks IncludesNoExec
    AllowOverride All
    Deny from none
  </Directory>
</VirtualHost>
<VirtualHost *:80>
  DocumentRoot "/home/vhosts/test/htdocs/"
  ServerName test.domain.com
  ErrorLog "/home/vhosts/test/logs/error.log"
  <Directory "/home/vhosts/test/htdocs/">
    Options FollowSymLinks IncludesNoExec
    AllowOverride All
    Deny from none
  </Directory>
</VirtualHost>

```

機種依存文字の抽出

PHP で機種依存文字をフィルタリングする関数を作ってみた | ウェブル

 

$pdc = '①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳㍉㌔㌢㍍㌘㌧㌃㌶㍑㍗㌍㌦㌣㌫㍊㌻㎜㎝㎞㎎㎏㏄㎡㍻〝〟㏍㊤㊥㊦㊧㊨㈲㈹㍾㍽㍼≒≡∫∮∑√⊥∠∟⊿∵∩∪纊褜鍈銈蓜俉炻昱棈鋹曻彅晥晗晙晴晳暙暠暲暿涖涬淏淸淲淼渹湜渧渼溿澈澵濵瀅瀇譿賰賴贒赶﨣軏﨤逸遧郞都鄕鄧釚釗釞釭釮釤釥鈆鈐鈊鈺鉀鈼鉎鉙鉑鈹鉧銧鉷鉸鋧鋗鋙鋐﨧鋕鋠鋓錥錡鋻﨨錞鋿錝錂鍰鍗鎤鏆鏞鏸鐱鑅鑈閒隆﨩隝隯霳霻靃靍靏靑靕顗顥飯飼餧館馞驎髙髜魵魲鮏鮱鮻鰀鵰鵫鶴鸙黑¬¦'"ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ¬㈱№℡∵纊褜鍈銈蓜俉炻昱棈鋹曻彅丨仡仼伀伃伹佖侒侊侚侔俍偀倢俿倞偆偰偂傔僴僘兊兤冝冾凬刕劜劦勀勛匀匇匤卲厓厲叝﨎咜咊咩哿喆坙坥垬埈埇﨏塚增墲夋奓奛奝奣妤妺孖寀甯寘寬尞岦岺峵崧嵓﨑嵂嵭嶸嶹巐弡弴彧德忞恝悅悊惞惕愠惲愑愷愰憘戓抦揵摠撝擎敎昀昕昻昉昮昞昤晥晗晙晴晳暙暠暲暿曺朎朗杦枻桒柀栁桄棏﨓楨﨔榘槢樰橫橆橳橾櫢櫤毖氿汜沆汯泚洄涇浯涖涬淏淸淲淼渹湜渧渼溿澈澵濵瀅瀇瀨炅炫焏焄煜煆煇凞燁燾犱犾猤猪獷玽珉珖珣珒琇珵琦琪琩琮瑢璉璟甁畯皂皜皞皛皦益睆劯砡硎硤硺礰礼神祥禔福禛竑竧靖竫箞精絈絜綷綠緖繒罇羡羽茁荢荿菇菶葈蒴蕓蕙蕫﨟薰蘒﨡蠇裵訒訷詹誧誾諟諸諶譓';
$pattern = '[' . $pdc . ']';
if (mb_ereg($pattern, $text)) {
$pdc_array = Array();
$pdc_text = str_replace(array("\r\n","\n","\r"), '', $text);

while($iLen = mb_strlen($pdc, 'UTF-8')) {
array_push($pdc_array, mb_substr($pdc, 0, 1, 'UTF-8'));
$pdc = mb_substr($pdc, 1, $iLen, 'UTF-8');
}
$error_str = '';
foreach($pdc_array as $value) {
if(preg_match("/(" . $value . ")/", $pdc_text)) {
$error_str .= $value;
}
}
if(!empty($error_str)){
$err_msg[$i] = $error_str."は機種依存文字のため、使用することができません。<br/>";
}
}