So, on my site, I use a couple different SSL cerficates. One for the root domain "illution.dk" and one for my subdomain "ci.illution.dk". Trouble is, when I fire a post request using HttpPost, and I request a URL like "https://ci.illution.dk/login/device", it just throws an error message saying:

I think this means that it is downloading the certificate of illution.dk, and then seeing that it does not support ci.illution.dk. However, everything is fine when I load up the browser and browse to "https://ci.illution.dk". My Android code is as follows:

Ok, it seems that it is an error with HttpPost, because if I use the code linked here it just works. I have modified the code to suit my specific needs, but here is my code: (Just in case the link goes down)

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//do this wherever you are wanting to POST
URL url;
HttpURLConnection conn;
try{
//if you are using https, make sure to import java.net.HttpsURLConnection
url=new URL("https://ci.illution.dk/login/device");
//you need to encode ONLY the values of the parameters
String param="username=" + URLEncoder.encode("usernametest","UTF-8")+
"&password="+URLEncoder.encode("passwordtest","UTF-8");
conn=(HttpURLConnection)url.openConnection();
//set the output to true, indicating you are outputting(uploading) POST data
conn.setDoOutput(true);
//once you set the output to true, you don't really need to set the request method to post, but I'm doing it anyway
conn.setRequestMethod("POST");
//Android documentation suggested that you set the length of the data you are sending to the server, BUT
// do NOT specify this length in the header by using conn.setRequestProperty("Content-Length", length);
//use this instead.
conn.setFixedLengthStreamingMode(param.getBytes().length);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
//send the POST out
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.print(param);
out.close();
//build the string to store the response text from the server
String response= "";
//start listening to the stream
Scanner inStream = new Scanner(conn.getInputStream());
//process the stream and store it in StringBuilder
while(inStream.hasNextLine())
response+=(inStream.nextLine());
Log.d("Test", response);
}
//catch some error
catch(MalformedURLException ex){
Toast.makeText(MainActivity.this, ex.toString(), 1 ).show();
}
// and some more
catch(IOException ex){
Toast.makeText(MainActivity.this, ex.toString(), 1 ).show();
}