GAE/JでSSL通信するとき | sola's note

sola's note

日ごろのメモを書いていきます。何か新しいものを作るために。

Google App Engine for JavaでSSL通信するとき

・appengine-web.xmlファイルに「ssl-enabled」を有効にする
<ssl-enabled>true</ssl-enabled>

・web.xmlファイルに「security-constraint」を記述する、
<security-constraint>
    <web-resource-collection>
        <url-pattern>/hoge/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

※「url-pattern」はSSL通信を行う対象により任意で設定して下さい。

Google App EngineのSSL通信は、ローカルの開発環境では動作しないため、
実際にテストや稼働を行う場合は、本番環境にデプロイする必要があります。

開発環境でアプリケーションの実行を行うと

YYYY/MM/DD h:mm:ss com.google.apphosting.utils.jetty.DevAppEngineWebAppContext disableTransportGuarantee
情報: Ignoring <transport-guarantee> for /hoge/* as the GK does not support HTTPS. It will still be used when you upload your application.

といったログがコンソールに出力されます。
この場合エラーではなく、HTTP通信で実行する形となります。