HTTPS経由でサーバーにPOSTリクエストを送信しようとすると、NullPointerExceptionが発生します。これは自己署名証明書ではありません(CheapSSLsによって発行されます)。
これは私が受け取っているエラーです:
06-21 18:52:37.757: E/AndroidRuntime(17985): FATAL EXCEPTION: AsyncTask #1
06-21 18:52:37.757: E/AndroidRuntime(17985): java.lang.RuntimeException: An error occured while executing doInBackground()
06-21 18:52:37.757: E/AndroidRuntime(17985): at android.os.AsyncTask$3.done(AsyncTask.java:200)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
06-21 18:52:37.757: E/AndroidRuntime(17985): at java.lang.Thread.run(Thread.java:1019)
06-21 18:52:37.757: E/AndroidRuntime(17985): Caused by: java.lang.NullPointerException
06-21 18:52:37.757: E/AndroidRuntime(17985): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:433)
06-21 18:52:37.757: E/AndroidRuntime(17985): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl$HttpsEngine.makeConnection(HttpsURLConnectionImpl.java:378)
06-21 18:52:37.757: E/AndroidRuntime(17985): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
06-21 18:52:37.757: E/AndroidRuntime(17985): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:614)
06-21 18:52:37.757: E/AndroidRuntime(17985): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:268)
私のコードは次のとおりです。
URL url = new URL(mUrl);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.168.1.134", 8888));
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection(proxy);
urlConnection.setRequestMethod("POST");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
MultipartBodyBuilder builder = new MultipartBodyBuilder();
builder.build(params);
urlConnection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + builder.mBoundary);
urlConnection.setFixedLengthStreamingMode(builder.getContentLength());
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(urlConnection.getOutputStream()));
getOutputStreamでコードがクラッシュします。
どんな助けでも大歓迎です。