SSLなしではてダラで投稿できない
SSLなしで はてダラを起動すると、記事がポストできなくなっていた。
どうすればいいかっていうと、cpan で Crypt::SSLeayを入れる。それだけ。
cpan でインストールするときに、テストをどうするか聞かれた気がする(うろ覚え)。
デフォルトが[N]だったから、実行しなかった。
問題発見
SSLなしで はてダラを起動すると、記事がポストできなくなっていた。
よくわからなくてググってみたのですが、はてダラでCrypt::SSLeayなしの情報がみつからない。とりあえず、投稿しないで放置していたのですが、休みになったので対策をすることにした。
SSLなしで はてダラを起動すると、記事がポストできない
$ /opt/local/bin/perl hw.pl -d
そのログが下のもの。
WARNING: Crypt::SSLeay is not found, use non-encrypted HTTP mode. DEBUG: Debug flag on. Hatena Diary Writer Version 1.4.1 Copyright (C) 2004,2005 by Hiroshi Yuki. DEBUG: Loading config file (config.txt). DEBUG: load_config: id:fu7mu4 DEBUG: load_config: password:******** DEBUG: main: files: current dir (.): ./2013-06-19.txt ./2013-06-20.txt ./2013-06-21.txt ./touch.txt Login to http://www.hatena.ne.jp/login as fu7mu4. DEBUG: login: 302 Found DEBUG: login: $r = <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="https://www.hatena.ne.jp/login">here</a>.</p> </body></html> Login OK. DEBUG: login: Making cookie jar. DEBUG: login: $cookie_jar = DEBUG: read_title_body: input: ./2013-06-19.txt Post 2013-06-19. DEBUG: create_it: 2013-06-19. DEBUG: create_it: 302 Moved DEBUG: create_it: Location: /fu7mu4/ DEBUG: create_it: returns 0 (ERROR). ERROR: try_it: Check username/password.
ここで 302 Not Foundがでている。
なんかはてな側で変更があったようですね。
httpでアクセスしようとしたら、ログインページがhttpsに移動した、そういうことみたいです。
じゃあ、 Crypt::SSLeay をインストールすれば、解決しそうですね。
Crypt::SSLeay をインストール
perl モジュールなので cpan でインストールです。
ルート権限でやればインストールできます。
こちらでは、 macport の perl を常用しているので cpan をフルパスで指定。
sudo /opt/local/bin/cpan
これで cpan が起動する。一般ユーザーだと、文句言われるはず。
Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.9456) Enter 'h' for help.
ひさしぶりなので、cpan の help を確認します。
cpan[1]> help
Display Information (ver 1.9456) command argument description a,b,d,m WORD or /REGEXP/ about authors, bundles, distributions, modules i WORD or /REGEXP/ about any of the above ls AUTHOR or GLOB about files in the author's directory (with WORD being a module, bundle or author name or a distribution name of the form AUTHOR/DISTRIBUTION) Download, Test, Make, Install... get download clean make clean make make (implies get) look open subshell in dist directory test make test (implies make) readme display these README files install make install (implies test) perldoc display POD documentation Upgrade r WORDs or /REGEXP/ or NONE report updates for some/matching/all modules upgrade WORDs or /REGEXP/ or NONE upgrade some/matching/all modules Pragmas force CMD try hard to do command fforce CMD try harder notest CMD skip testing Other h,? display this menu ! perl-code eval a perl command o conf [opt] set and query options q quit the cpan shell reload cpan load CPAN.pm again reload index load newer indices autobundle Snapshot recent latest CPAN uploads
では、Crypt::SSLeay の インストールです。
cpan[2]> install Crypt::SSLeay
この記録です。
Going to read '/Users/fu7mu4/.cpan/Metadata' Database was generated on Thu, 21 Mar 2013 23:08:41 GMT Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/authors/01mailrc.txt.gz Going to read '/Users/fu7mu4/.cpan/sources/authors/01mailrc.txt.gz' ............................................................................DONE Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/modules/02packages.details.txt.gz Going to read '/Users/fu7mu4/.cpan/sources/modules/02packages.details.txt.gz' Database was generated on Sat, 22 Jun 2013 00:53:02 GMT .............. New CPAN.pm version (v2.00) available. [Currently running version is v1.9456] You might want to try install CPAN reload cpan to both upgrade CPAN.pm and run the new version without leaving the current session. ..............................................................DONE Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/modules/03modlist.data.gz Going to read '/Users/fu7mu4/.cpan/sources/modules/03modlist.data.gz' ............................................................................DONE Going to write /Users/fu7mu4/.cpan/Metadata Running install for module 'Crypt::SSLeay' Running make for N/NA/NANIS/Crypt-SSLeay-0.64.tar.gz Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/authors/id/N/NA/NANIS/Crypt-SSLeay-0.64.tar.gz Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/authors/id/N/NA/NANIS/CHECKSUMS Checksum for /Users/fu7mu4/.cpan/sources/authors/id/N/NA/NANIS/Crypt-SSLeay-0.64.tar.gz ok Scanning cache /Users/fu7mu4/.cpan/build for sizes ............................................................................DONE CPAN.pm: Going to build N/NA/NANIS/Crypt-SSLeay-0.64.tar.gz The test suite can attempt to connect to public servers to ensure that the code is working properly. If you are behind a strict firewall or have no network connectivity, these tests may fail (through no fault of the code). Do you want to run the live tests (y/N)? [N] Checking if your kit is complete... Looks good Warning: prerequisite Try::Tiny 0.09 not found. Note (probably harmless): No library found for -lssl32 Note (probably harmless): No library found for -lssleay32 Note (probably harmless): No library found for -leay32 Writing Makefile for Crypt::SSLeay ---- Unsatisfied dependencies detected during ---- ---- NANIS/Crypt-SSLeay-0.64.tar.gz ---- Try::Tiny [requires] Running make test Delayed until after prerequisites Running make install Delayed until after prerequisites Running install for module 'Try::Tiny' Running make for D/DO/DOY/Try-Tiny-0.12.tar.gz Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/authors/id/D/DO/DOY/Try-Tiny-0.12.tar.gz Fetching with LWP: ftp://ftp.u-aizu.ac.jp/pub/CPAN/authors/id/D/DO/DOY/CHECKSUMS Checksum for /Users/fu7mu4/.cpan/sources/authors/id/D/DO/DOY/Try-Tiny-0.12.tar.gz ok CPAN.pm: Going to build D/DO/DOY/Try-Tiny-0.12.tar.gz Checking if your kit is complete... Looks good Writing Makefile for Try::Tiny cp lib/Try/Tiny.pm blib/lib/Try/Tiny.pm Manifying blib/man3/Try::Tiny.3pm DOY/Try-Tiny-0.12.tar.gz /usr/bin/make -- OK 'YAML' not installed, will not store persistent state Running make test PERL_DL_NONLAZY=1 /opt/local/bin/perl5.12 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/basic.t ....... ok t/context.t ..... ok t/finally.t ..... ok t/given_when.t .. ok t/when.t ........ ok All tests successful. Files=5, Tests=85, 0 wallclock secs ( 0.06 usr 0.03 sys + 0.19 cusr 0.04 csys = 0.32 CPU) Result: PASS DOY/Try-Tiny-0.12.tar.gz /usr/bin/make test -- OK Running make install Installing /opt/local/lib/perl5/site_perl/5.12.4/Try/Tiny.pm Installing /opt/local/share/perl5.12/siteman/man3/Try::Tiny.3pm Appending installation info to /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level/perllocal.pod DOY/Try-Tiny-0.12.tar.gz /usr/bin/make install -- OK Running make for N/NA/NANIS/Crypt-SSLeay-0.64.tar.gz Has already been unwrapped into directory /Users/fu7mu4/.cpan/build/Crypt-SSLeay-0.64-48GmsV CPAN.pm: Going to build N/NA/NANIS/Crypt-SSLeay-0.64.tar.gz cp lib/Crypt/SSLeay/X509.pm blib/lib/Crypt/SSLeay/X509.pm cp lib/Net/SSL.pm blib/lib/Net/SSL.pm cp SSLeay.pm blib/lib/Crypt/SSLeay.pm cp lib/Crypt/SSLeay/CTX.pm blib/lib/Crypt/SSLeay/CTX.pm cp lib/Crypt/SSLeay/Conn.pm blib/lib/Crypt/SSLeay/Conn.pm cp lib/Crypt/SSLeay/MainContext.pm blib/lib/Crypt/SSLeay/MainContext.pm cp lib/Crypt/SSLeay/Err.pm blib/lib/Crypt/SSLeay/Err.pm /opt/local/bin/perl5.12 /opt/local/lib/perl5/site_perl/5.12.4/ExtUtils/xsubpp -typemap /opt/local/lib/perl5/5.12.4/ExtUtils/typemap -typemap typemap SSLeay.xs > SSLeay.xsc && mv SSLeay.xsc SSLeay.c /usr/bin/clang -c -pipe -O2 -fno-common -DPERL_DARWIN -I/opt/local/include -no-cpp-precomp -fno-strict-aliasing -fstack-protector -I/opt/local/include -O3 -DVERSION=\"0.64\" -DXS_VERSION=\"0.64\" "-I/opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level/CORE" SSLeay.c Running Mkbootstrap for Crypt::SSLeay () chmod 644 SSLeay.bs rm -f blib/arch/auto/Crypt/SSLeay/SSLeay.bundle LD_RUN_PATH="/opt/local/lib" env MACOSX_DEPLOYMENT_TARGET=10.8 /usr/bin/clang -L/opt/local/lib -bundle -undefined dynamic_lookup -fstack-protector SSLeay.o -o blib/arch/auto/Crypt/SSLeay/SSLeay.bundle \ -lz -lssl -lcrypto \ chmod 755 blib/arch/auto/Crypt/SSLeay/SSLeay.bundle cp SSLeay.bs blib/arch/auto/Crypt/SSLeay/SSLeay.bs chmod 644 blib/arch/auto/Crypt/SSLeay/SSLeay.bs Manifying blib/man3/Net::SSL.3pm Manifying blib/man3/Crypt::SSLeay.3pm NANIS/Crypt-SSLeay-0.64.tar.gz /usr/bin/make -- OK Running make test PERL_DL_NONLAZY=1 /opt/local/bin/perl5.12 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00-basic.t .... ok t/01-connect.t .. ok t/02-live.t ..... # Reading configuration from 'test.config' on darwin # network_tests : 0 t/02-live.t ..... skipped: Network tests disabled All tests successful. Files=3, Tests=20, 1 wallclock secs ( 0.03 usr 0.02 sys + 0.27 cusr 0.04 csys = 0.36 CPU) Result: PASS NANIS/Crypt-SSLeay-0.64.tar.gz /usr/bin/make test -- OK Running make install Files found in blib/arch: installing files in blib/lib into architecture dependent library tree Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/auto/Crypt/SSLeay/SSLeay.bs Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/auto/Crypt/SSLeay/SSLeay.bundle Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Crypt/SSLeay.pm Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Crypt/SSLeay/CTX.pm Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Crypt/SSLeay/Conn.pm Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Crypt/SSLeay/Err.pm Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Crypt/SSLeay/MainContext.pm Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Crypt/SSLeay/X509.pm Installing /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level/Net/SSL.pm Installing /opt/local/share/perl5.12/siteman/man3/Crypt::SSLeay.3pm Installing /opt/local/share/perl5.12/siteman/man3/Net::SSL.3pm Appending installation info to /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level/perllocal.pod NANIS/Crypt-SSLeay-0.64.tar.gz /usr/bin/make install -- OK
インストールは終了したようです。cpan を抜けます。
cpan[3]> bye
Terminal does not support GetHistory. Lockfile removed.
これでいいのかな。というわけで、はてダラで投稿テストです。
はてダラで投稿
/opt/local/bin/perl hw.pl -d
その記録です。
DEBUG: Debug flag on. Hatena Diary Writer Version 1.4.1 Copyright (C) 2004,2005 by Hiroshi Yuki. DEBUG: Loading config file (config.txt). DEBUG: load_config: id:fu7mu4 DEBUG: load_config: password:******** DEBUG: main: files: current dir (.): ./2013-06-19.txt ./2013-06-20.txt ./2013-06-21.txt ./touch.txt Login to https://www.hatena.ne.jp/login as fu7mu4. DEBUG: login: 200 OK DEBUG: login: $r = <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html lang="ja" data-device="pc" data-theme=""> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>はてな</title> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"><link rel="stylesheet" href="/css/simple-header.css" type="text/css" media="all"> <script type="text/javascript" src="/js/Ten/Ten.js"></script> <link rel="stylesheet" href="/css/base.css"> <link rel="stylesheet" href="/statics/css/hatena-www-jp.css"> <meta http-equiv="Refresh" content="1;URL=http://d.hatena.ne.jp/fu7mu4/" /> </head><body id="hatena-www-login" class=""> <div id="header" align="left"> <div id="logo"><a href="/"><img src="/statics/images/logo-hatena-global.gif" alt="Hatena" title="Hatena" id="logo-hatena" /></a></div> </div> <div id="container"> <div id="body"> <div class="progress-message"> <p><span>fu7mu4 でログイン中です</span></p> <div class="note">自動的に移動しない場合は<a href="http://d.hatena.ne.jp/fu7mu4/">こちら</a>をクリックしてください。 </div> </div> </div> </div> <div id="footer"> <div class="menu"><a href="//www.hatena.ne.jp/">ホーム</a> - <a href="//www.hatena.ne.jp/rule/rule">利用規約</a> - <a href="//www.hatena.ne.jp/rule/privacypolicy">プライバシーポリシー</a> - <a href="//www.hatena.ne.jp/faq/">お問い合わせ</a> - <a href="//www.hatena.ne.jp/company/tokutei">特定商取引法に基づく表示</a> - <a href="//www.hatena.ne.jp/company/shikin">資金決済法に基づく表示</a> <script type="text/javascript"> if (typeof Ten == "undefined") { document.write('<scr' + 'ipt type="text/javascript" src="//www.hatena.ne.jp/js/Ten/Ten.js">' + '</scr' + 'ipt>'); } </script> <script src="//www.hatena.com/js/locale-all.js" type="text/javascript"></script> <script src="//www.hatena.com/js/updu/ten-extras.js" charset=utf-8></script> <script src="//www.hatena.com/js/Hatena/LangSelector.js" type="text/javascript"></script> <div id="langselector" style="display:none;background-color:#ffffff;border:3px solid #1841CE; padding:1em;text-align:left"> <div id="langselector-title">表示言語を選択</div> <div id="langselector-body"> <ul> <li class="selected"><a id="ja" href="https://www.hatena.ne.jp/login?locale.lang=ja" rel="alternate" hreflang="ja">日本語</a> </li> <li ><a id="en" href="https://www.hatena.ne.jp/login?locale.lang=en" rel="alternate" hreflang="en">English</a> </li> <li ><a id="en-gb" href="https://www.hatena.ne.jp/login?locale.lang=en-gb" rel="alternate" hreflang="en-gb">English (UK)</a> </li> <li ><a id="fr" href="https://www.hatena.ne.jp/login?locale.lang=fr" rel="alternate" hreflang="fr">Français</a> </li> <li ><a id="it" href="https://www.hatena.ne.jp/login?locale.lang=it" rel="alternate" hreflang="it">Italiano</a> </li> <li ><a id="es" href="https://www.hatena.ne.jp/login?locale.lang=es" rel="alternate" hreflang="es">Español</a> </li> <li ><a id="de" href="https://www.hatena.ne.jp/login?locale.lang=de" rel="alternate" hreflang="de">Deutsch</a> </li> </ul> </div> </div> </div> <div id="copyright">Copyright (C) 2001-2013 hatena. All Rights Reserved.</div> </div> </body> </html> Login OK. DEBUG: login: Making cookie jar. DEBUG: get_rkm: $rkm = gApc6HSvPZfVQh9eXtIgsw DEBUG: login: $cookie_jar = Set-Cookie3: b=$1$sVY1W93w$Z3Chk3gVtRY7uFZezGryH.; path="/"; domain=.hatena.ne.jp; path_spec; expires="2033-06-17 16:14:01Z"; version=0 Set-Cookie3: rk=7d2a56d4d978f2bdbe732091cc4f1f6c1ba1fd4f; path="/"; domain=.hatena.ne.jp; path_spec; discard; version=0 DEBUG: read_title_body: input: ./2013-06-19.txt Post 2013-06-19. DEBUG: create_it: 2013-06-19. DEBUG: create_it: 302 Moved DEBUG: create_it: Location: http://d.hatena.ne.jp/fu7mu4/20130619 DEBUG: create_it: returns 1 (OK). DEBUG: post_it: 2013-06-19. DEBUG: post_it: 302 Moved DEBUG: post_it: Location: http://d.hatena.ne.jp/fu7mu4/20130619 DEBUG: post_it: returns 1 (OK). Post OK. DEBUG: read_title_body: input: ./2013-06-20.txt Post 2013-06-20. DEBUG: create_it: 2013-06-20. DEBUG: create_it: 302 Moved DEBUG: create_it: Location: http://d.hatena.ne.jp/fu7mu4/20130620 DEBUG: create_it: returns 1 (OK). DEBUG: post_it: 2013-06-20. DEBUG: post_it: 302 Moved DEBUG: post_it: Location: http://d.hatena.ne.jp/fu7mu4/20130620 DEBUG: post_it: returns 1 (OK). Post OK. DEBUG: read_title_body: input: ./2013-06-21.txt Post 2013-06-21. DEBUG: create_it: 2013-06-21. DEBUG: create_it: 302 Moved DEBUG: create_it: Location: http://d.hatena.ne.jp/fu7mu4/20130621 DEBUG: create_it: returns 1 (OK). DEBUG: post_it: 2013-06-21. DEBUG: post_it: 302 Moved DEBUG: post_it: Location: http://d.hatena.ne.jp/fu7mu4/20130621 DEBUG: post_it: returns 1 (OK). Post OK. Logout from http://d.hatena.ne.jp as fu7mu4. DEBUG: logout: 200 OK Logout OK.
できてるっぽい。ブラウザから確認するとちゃんと表示されました。
うまくいきました。
さらにsimple-hatena-modeで
simple-hatena-modeから投稿できた。よしよし。