I am trying to login my application using my php server ..it works fine when my server url is like http://www.myservername.com/login.php but when my server address starts with https:// like https://www.myservername.com/login.php then problem arise it giving me exception
javax.net.ssl.sslpeerunverifiedexception no peer certificate
my code is below.
public class Main extends Activity {
public static DefaultHttpClient client;
EditText useremail;
EditText password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button login_button= (Button) findViewById(R.id.login_button);
login_button.setOnClickListener(new View.OnClickListener() {
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
try{
useremail=(EditText) findViewById(R.id.useremail);
String useremail_string=useremail.getText().toString();
password=(EditText) findViewById(R.id.password);
String password_string=password.getText().toString();
if("".equals(useremail_string) || "".equals(password_string)){
Toast.makeText(getApplicationContext(), "Empty field detected", Toast.LENGTH_SHORT).show();
}//empty check
/***Login process begin***/
else{
String s="";
String d="";
try {
StrictMode.enableDefaults();
JSONObject json = new JSONObject();
json.put("username", useremail_string);
json.put("password", password_string);
client = new DefaultHttpClient();
String url = "https://www.myservername.com/mobile_app/login/check_user";
HttpPost request = new HttpPost(url);
request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
request.setHeader("json", json.toString());
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null){
InputStream instream = entity.getContent();
String result="";
try{
BufferedReader reader= new BufferedReader(new InputStreamReader(instream,"iso-8859-1"),8);
StringBuilder sb=new StringBuilder();
String line=null;
while((line=reader.readLine())!=null){
sb.append(line+"\n"); }
instream.close();
result= sb.toString();
}catch(Exception e){}
JSONArray jArray= new JSONArray(result);
JSONObject getjson=jArray.getJSONObject(0);
s=getjson.getString("message");
d=getjson.getString("data");
if("success".equals(s))
{
password.setText(null);
SharedPreferences share= getSharedPreferences("Userdata", Context.MODE_PRIVATE);
SharedPreferences.Editor editor=share.edit();
editor.putString("session_value", d);
editor.commit();
Intent profile=new Intent(Main.this,BidActivity.class);
profile.putExtra(EXTRA_MESSAGE, d);
startActivity(profile);
}
else
{
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
}}
}catch(Throwable t){}
}
/***Login process end***/
}catch(Exception e){ }
}});
}
}// end of function onCreate
}//end of class
please help guys...