2018/05/27

[Windows] リネームしたはずのフォルダ名が元の名前に戻ってしまう

Explorer からフォルダ名変更 → 他のフォルダに移動すると、元の名前に戻ってしまう。
変更後にフォルダのプロパティを見ると、[全般]タブでは変更後の名前になっているが、隣の[共有]タブでは変更前の名前のままになっていることが確認できる。
原因は多岐にわたるようだが、当該フォルダ内の「隠しファイル」が影響している場合がある。

<autorun.infが影響する場合>
If this problem occurs again, enable hidden items to be shown in windows explorer. Find a Setup Information File called "autorun.inf" and edit or delete this file with administrator rights. Restart your computer and your problem should be fixed.

autorun.inf

[Autorun]
Label=Drive

https://social.technet.microsoft.com/Forums/en-US/b4da4617-f4ec-465e-a43d-f7e365784f99/still-cant-rename-folders-in-windows-10-file-explorer?forum=win10itprogeneral

他にも「desktop.ini」が影響する場合等々。
隠しファイルを表示できる状態にし、当該ファイルを削除で事象解消できることを確認

2018/05/21

[Ruby] `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate) (OpenSSL::SSL::SSLError)

証明書を検証をしない方法でエラー抑止

require 'open-uri'
require 'openssl'
puts open('https://www.google.com/', :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE).read

[Ruby] open-uri の HTTPS リクエストで certificate verify failed
http://mofuken.blogspot.jp/2012/12/ruby-open-uri-https-certificate-verify.html

2018/05/17

[セキュリティ] certbot で Let's Encrypt 証明書更新

sudo /usr/local/bin/certbot \
    certonly \
    --webroot \
    -d example.com\
    -w /var/app/current/example.com

[aws] Elastic Beanstalk 単一インスタンス+ワイルドカード証明書(Let's Encrypt)で http 通信を利用する際の設定

Elastic Load Balancing(ELB)使用時は、Certificate Managerで作成したSSL証明書適用でOKだが、シングルインスタンスではNGなので、自前の証明書を適用。

<証明書取得>
certbot インストール
sudo pip install certbot

Zone APEX用証明書
sudo /usr/local/bin/certbot certonly \
--manual \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
--domains example.com

SSLCertificateFile    "/etc/letsencrypt/live/example.com/fullchain.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/example.com/privkey.pem"
が生成。
Route 53 で _acme-challenge.example.com の TXTレコードに指示された値を設定し、有効化。


ワイルドカードサブドメイン用証明書
sudo /usr/local/bin/certbot certonly \
--manual \
--preferred-challenges dns-01 \
--server https://acme-v02.api.letsencrypt.org/directory \
--domains *.example.com

SSLCertificateFile    "/etc/letsencrypt/live/example.com-0001/fullchain.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/example.com-0001/privkey.pem"
が生成。
Route 53 で _acme-challenge.example.com の TXTレコードに指示された値を設定し、有効化。


<証明書設定>

/etc/httpd/conf.d/ssl.conf
以下の通り設定

  LoadModule ssl_module modules/mod_ssl.so
  Listen 443
  NameVirtualHost *:443

  <VirtualHost *:443>
    ServerName example.com
    DocumentRoot "/var/app/current/example/example.com"
    SSLEngine             on
    SSLCertificateFile    "/etc/letsencrypt/live/example.com-0001/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/example.com-0001/privkey.pem"
    <Directory "/var/app/current/example/example.com">
      AllowOverride All
      Require all granted
    </Directory>
  </VirtualHost>

  <VirtualHost *:443>
    ServerName example.com
    DocumentRoot "/var/app/current/example/sub.example.com"
    SSLEngine             on
    SSLCertificateFile    "/etc/letsencrypt/live/example.com/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/example.com/privkey.pem"
    <Directory "/var/app/current/example/sub.example.com">
      AllowOverride All
      Require all granted
    </Directory>
  </VirtualHost>

  SSLCipherSuite        EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
  SSLProtocol           All -SSLv2 -SSLv3
  SSLHonorCipherOrder   On
  SSLSessionTickets     Off
  Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
  Header always set X-Frame-Options DENY
  Header always set X-Content-Type-Options nosniff

サーバ再起動後、SSL Sever Test にて確認。


installation error on amazon linux
https://github.com/certbot/certbot/issues/1680#issuecomment-358728515

CertbotでDNSによる認証(DNS-01)で無料のSSL/TLS証明書を取得する
http://blog.jicoman.info/2017/04/certbot_dns_01/

Let's Encryptのワイルドカード証明書を早速発行してもらう
https://narusejun.com/archives/23/

付録: Amazon Linux 2 での Let's Encrypt と Certbot の使用
https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/SSL-on-an-instance.html

SSL Server Test
https://www.ssllabs.com/ssltest/

2018/05/12

[Apache] xamppで https 利用するための自己署名証明書の作成方法

XAMPP for WindowsでSSLを有効にする
https://qiita.com/sutara79/items/21a068494bc3a08a4803


1. C:\xampp\apache\conf\extra\httpd-ssl.conf に VirtualHost設定

<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/my-server.crt"
    SSLCertificateKeyFile "conf/ssl.key/my-server.key"
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs"
    ServerName test.localhost
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/my-server.crt"
    SSLCertificateKeyFile "conf/ssl.key/my-server.key"
</VirtualHost>


2. C:\xampp\apache\conf\openssl.cnf 編集

[ req ]セクション
x509_extensions = v3_ca # The extensions to add to the self signed cert
→ x509_extensions = v3_req # The extensions to add to the self signed cert

末尾追記
[ SAN ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = localhost
DNS.2 = test.localhost
# DNS.3 = <他に認証したいドメインがあれば>

→ *.localhost の設定はNG(事由不明)


3. openssl(Git Bash)で証明書作成

cd /c/xampp/apache/conf
openssl req \
    -newkey     rsa:4096 \
    -keyout     my-server.key \
    -x509 \
    -nodes \
    -out        my-server.crt \
    -subj       "//CN=localhost" \
    -reqexts    SAN \
    -extensions SAN \
    -config     openssl.cnf \
    -days       3650


4. 証明書設置
C:\xampp\apache\conf\ssl.crt\my-server.crt
C:\xampp\apache\conf\ssl.key\my-server.key


5. 証明書認証
C:\xampp\apache\conf\ssl.crt\my-server.crt ダブルクリック
→ [証明書のインストール]
→ [保存場所] 現在のユーザー → [次へ]
→ 証明書をすべて次のストアに配置する、[証明書ストア] 信頼されたルート証明機関 → [次へ]
→ [完了] → [はい]


6. Firefoxで自己署名証明書認証の例外設定

2018/05/10

[aws] スナップショットからボリューム復元後に ssh 接続できない

EBSでスナップショットからボリューム作成
→ アタッチ
→ ec2 インスタンス停止
→ 現ボリュームデタッチ
→ 新ボリュームアタッチ
→ インスタンス再起動
で、ssh 接続試みると WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! の警告表示され、ログイン不可。

接続サーバの fingerprint が変化して、なりすましの可能性を検知したため。
ssh-keygen -R hostname (ex. ec2-xx-xx-xx-xxx.ap-northeast-1.compute.amazonaws.com) にて解消。

Windows では ssh-keygen -R 未サポートなので Git-Bash から実行

SSH接続エラー回避方法:.ssh/known_hostsから特定のホストを削除する/削除しないで対処する3つの方法
https://qiita.com/grgrjnjn/items/8ca33b64ea0406e12938

2018/05/09

[TLS] 分かりやすいテキスト形式で証明書の内容を出力する

Windows上で、証明書や秘密鍵をPEM形式に変換してエクスポートする
http://www.atmarkit.co.jp/ait/articles/1602/05/news039.html


C:\temp>openssl x509 -inform PEM -text -noout -in example2.cer ……「example2.cer」の内容を表示させてみる

opensslコマンドの各オプションの意味は次の通りだ。

x509: 証明書を取り扱うためのコマンド
-inform PEM: 入力ファイルの形式としてPEMを指定する(デフォルトの形式はPEMなので、通常は明示的に指定する必要はない)
-text: 分かりやすいテキスト形式で証明書の内容を出力する
-noout: 証明書をファイルに出力しない
-in <ファイル名>: 入力ファイルの指定(この場合は証明書ファイル)

2018/05/06

[Apache] クローラーBot対策

(1) robots.txt で Disallow

(2) .htaccess で BrowserMatchNoCase で環境変数設定して、deny from env=その環境変数

Chrome / Firefox の User-agent 偽装アドオンをインストールして確認

2018/05/05

[aws] Elastic Beanstalk で DocumentRoot 配下に WinSCPでファイルを書き込めない

/var 配下に書き込み権がないたいため

# ec2-userでssh接続
sudo chmod -R 755 /var/www/html #フォルダのアクセス権限を変更
sudo chown -R ec2-user /var/www/html #一応オーナーも変更

# Elastic Beanstalk では
sudo chmod -R 755 /var/app/current
sudo chown -R ec2-user /var/app/current

CyberduckでEC2(Amazon Linux AMI)にファイルをアップロードできない
https://teratail.com/questions/22478

[Windows] 「最近使った項目」を復活+スタートメニューにピン留めする

クイックアクセスには表示したくないが、機能は使いたい

「最近使った項目」を復活+スタートメニューにピン留めする
https://news.mynavi.jp/article/win10tips-132/

2018/05/04

[Apache] localhost で 400 Bad Request

ホスト名に_(アンダースコア)を使ったため。ハイフンに修正して解消

Xamppにおいて、Apacheのバーチャルホストの設定でBad Requestが出る
https://teratail.com/questions/80836

Apache ローカル環境 400 Bad Request になるとき
https://chaika.hatenablog.com/entry/2018/01/26/090000

[Windows] 右クリックメニューに複数存在する「FAX受信者」を1つにする

Win 10 1803アップグレード後に、例によって「FAX受信者」が増えたので、余分なものを削除する

Windows10のコンテキストメニューをいじってみる その2
http://blog.livedoor.jp/lost_elysium/archives/1916371.html

WINDOWS10にアップグレードした後、ファイルを右クリックして、「送る」... - Yahoo!知恵袋
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10148853345

2018/05/03

[メール] mailto: リンクを Gmail で開く

mailto:のメールリンクをGMAILで開くようにする設定の仕方
http://www.kagua.biz/tool/chrome-extension/mailto-gmail-handler.html

2018/05/01

[Windows] Windows 10 メジャーアップデート時に行うレジストリ再設定

一部設定が初期化されてしまうので、再度レジストリを設定しなおし

Windows 10で「Windowsフォトビューワー」を使う方法
http://ascii.jp/elem/000/001/078/1078506/

[Shift]+右クリックメニューに「コマンドウィンドウをここで開く」を復活させる方法
http://www.atmarkit.co.jp/ait/articles/1709/15/news025.html

Windows 10のPCが、数分で勝手にスリープするのを防ぐ
http://www.atmarkit.co.jp/ait/articles/1803/22/news018.html

Windowsで特定のフォルダを仮想ドライブとしてマウントする方法
http://did2memo.net/2012/06/19/how-to-mount-folder-as-virtual-drive-windows/

[Fix] Search Results defaults to Content View in Windows 10
http://www.winhelponline.com/blog/search-results-content-view-fix-details-windows-10/