PDA

View Full Version : IMAP - unable to get local issuer certificate



nuttycoder
09-11-2008, 09:24 AM
Hi am having problems,

I'm building a mail reader for a uni project I want to login with different email providers which I have got working locally I can login with an gmail, aol, aim email address and see my mail.

I cannot do this on my bluehost server as I could not make outbound connections so I bought a dedicated IP and I always get unable to get local issuer certificate error like:


Certificate failure for imap.aol.com: /C=US/ST=Virginia/L=Dulles/O=America Online Inc./CN=AOL Member CA

I have spoken to bluehost about this its ongoing has been for days but as yet its not been resolved I was hoping someone knew what the problem is or how to fix it.

This is the code I use to login to the mail account



function login($username, $password){

//get form data
$username = trim($_POST['username']);
$password = trim($_POST['password']);

//strip all tags from varible
$username = strip_tags($username);
$password = strip_tags($password);

if($username == '' || $password == ''){
global $errorMessage;
$errorMessage = '<p><span class="warning">Please enter your email address and password!</span></p>';
}

$arr = explode('@', $username);
$host = trim(stripslashes($arr[1]));

if (preg_match("/karoo/i", $host)) {
$host = 'karoo.co.uk';
}


if($host == 'hotmail.com' || $host == 'hotmail.co.uk' || $host == 'msn.com' || $host == 'live.com' || $host == 'lycos.com' || $host == 'lycos.co.uk'){
global $errorMessage;
$errorMessage = '<p><span class="warning">Sorry Hotmail, msn, live, lycos users cannot use this service at this time.</span></p>'; }

if(!$errorMessage)
{

switch($host){
case "nuttycoder.net":
$host = '{mail.nuttycoder.net:143/notls/norsh}';
break;
case "karoo.co.uk":
$host = '{pop.karoo.co.uk:110/pop3}';
break;
case "aol.com":
$host = '{imap.aol.com:143/imap}';
break;
case "aim.com":
$host = '{imap.aol.com:143/imap}';
break;
case "lycos.co.uk":
$host = '{mail.lycos.co.uk:143/pop3}';
break;
case "yahoo.com":
$host = '{mail.yahoo.com:110/pop3}';
break;
case "hotmail.com":
$host = '{207.46.106.175:1863/imap}';
break;
case "msn.com":
$host = '{mail.pop3hot.com:143/imap}';
break;
case "googlemail.com":
$host = '{imap.gmail.com:993/imap/ssl}';
break;
case "gmail.com":
$host = '{imap.gmail.com:993/imap/ssl}';
break;
default:
$host = '{mail.'.$host.':143}';
}

if(@imap_open($host, $username,$password)or die(imap_last_error()))
{

$_SESSION['ho'] = $host;
$_SESSION['us'] = $username;
$_SESSION['pa'] = $password;

// reload the page
header('Location: '.$_SERVER['HTTP_REFERER']);
exit;
} else {
//make error message avalible outside of function
global $errorMessage;
// define an error message
$errorMessage = '<p><span class="warning">Sorry you cannot login there is a problem: '.imap_last_error()."</span></p>\n";
}
}
}


I'd really appreciate some help as my project is on hold until I can find a fix for this.

you can test the sample application at http://webguideuk.com/amail

nuttycoder
09-12-2008, 01:14 AM
problem has been fixed:



The problem is, the certificate's aren't matching, the SSL certificates are set for gmail and aol websites, but because you're attempting to create a connection from webguideuk.com and not gmail.com or aol.com, the PHP imap interface is rejecting the connection because of the certificates. You'll need to add /novalidate-cert to you imap_open line so it doesn't check the certificates. See http://us.php.net/manual/en/function.imap-open.php for more information.