|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-06-28 18:03 UTC] ed2019 at columbia dot edu
Description:
------------
Running stock RHEL4 on Intel, with stock RedHat RPMS of php & everything else, all maintained with up2date.
imap_open() fails with the following error message, if the target IMAP server advertises GSSAPI:
[client ip.ip.ip.ip] PHP Notice: (null)(): GSSAPI failure: Credentials cache permissions incorrect (errflg=1) in Unknown on line 0
[client ip.ip.ip.ip] PHP Notice: (null)(): Can not authenticate to IMAP server: Client canceled authentication (errflg=2) in Unknown on line 0
[client ip.ip.ip.ip] PHP Warning: imap_open(): Couldn't open stream {ip.ip.ip.ip:993/imap/ssl/novalidate-cert} in /var/www/html/testimap.php
on line 3
Reproduce code:
---------------
$mbox = imap_open("{mailhost:993/imap/ssl/novalidate-cert/norsh}INBOX", "username", "pw");
Expected result:
----------------
$mbox should have been a valid imap resource.
Actual result:
--------------
From /var/log/httpd/error_log
[client ip.ip.ip.ip] PHP Notice: (null)(): GSSAPI failure: Credentials cache permissions incorrect (errflg=1) in Unknown on line 0
[client ip.ip.ip.ip] PHP Notice: (null)(): Can not authenticate to IMAP server: Client canceled authentication (errflg=2) in Unknown on line 0
[client ip.ip.ip.ip] PHP Warning: imap_open(): Couldn't open stream {ip.ip.ip.ip:993/imap/ssl/novalidate-cert} in /var/www/html/testimap.php
on line 3
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 09:00:02 2025 UTC |
If you happen to run across this error while attempting to connect to an Exchange server....... In my case Exchange 2007 from Ubuntu Install Kerberos client i.e heimdal-client Switch to the apache user....for Ubuntu that is "www-data": su www-data kinit username@DOMAINNAME.COM 'Mind the case lower@UPPER klist 'Will show current ticket granting ticket and other tokens Note: krbtgt will expire and this procedure will need to be repeated I am currently researching a method to ensure an active krbtgt at all times Try testing with this script as the apache user, replacing ipaddress, username, domainname and password. <?php $mbox = imap_open("{ipaddress:993/imap/ssl/novalidate-cert/notls/debug}INBOX", "domainname/username", "password") or die(imap_last_error()."<br>Connection Failure!"); echo "<h1>Mailboxes</h1>\n"; $folders = imap_listmailbox($mbox, "{ipaddress:993}", "*"); if ($folders == false) { echo "Call failed<br />\n"; } else { foreach ($folders as $val) { echo $val . "<br />\n"; } } echo "<h1>Headers in INBOX</h1>\n"; $headers = imap_headers($mbox); if ($headers == false) { echo "Call failed<br />\n"; } else { foreach ($headers as $val) { echo $val . "<br />\n"; } } imap_close($mbox); ?>I can't connect to Exchange 2007 sp1 PHP running on Windows 2000 C:\php>php -v PHP 5.2.8 (cli) (built: Dec 8 2008 19:31:23) with Pear Net_POP3 1.3.6 stable example from getMessage() after logon... Error in authentication: USER NOT supported authentication method!. This server supports these methods: GSSAPI, but I support APO P,PLAIN,LOGIN,USERHi- I was the original submitter of this bug four years ago, but I felt I should write to clear up a little confusion which has popped up from pajoye at php.net . Mark Crispin's c-client (which is the library underlying PHP's IMAP stuff) can authenticate to IMAP servers using various methods, including but not limited to PLAIN and GSSAPI. You can specify when calling the c-client library which authentication method to use. When you're going to authenticate with kerberos/GSSAPI, you would provide a certain set of client credentials. When you want to authenticate with PLAIN, you provide a different set of credentials (namely, username and password). The problem with PHP's imap_open() is that it does not allow you to specify which of these authentication methods to use, nor does it guess correctly from the credentials you provide it. The setup, as I encountered it, is/was: 1) Your code wants to authenticate to an IMAP server with a username & password. These credentials are appropriate for PLAIN authentication. 2) You call imap_open() and pass it the username & password. 3) imap_open() (through c-client) contacts the server attempts to authenticate via GSSAPI, which fails. imap_open() then gives up. So, the bug in this case is that imap_open needs an argument of some sort which tells it NOT to try using GSSAPI, and instead to try using PLAIN authentication. Perhaps something like [authmethod ={PLAIN || GSSAPI || ...}] , which would then be passed through to the c-client implementation. Make no mistake about it, there is no way around this bug with PHP's broken imap_open(). If you have an imap server which advertises both authentication methods, there is no way to authenticate to that server with the PLAIN method - even though the server is configured correctly, and the underlying c-client IMAP library supports it. imap_open() is not tickling the c-client library correctly to get the proper result.Hi again- In response to the reference to Joe's comment on the red hat bug list about how the c-client code stops retrying, my response is - so what? Many other applications built on top of c-client manage to authenticate via IMAP / PLAIN to these same servers. The key is that c-client already includes a mechanism for connecting to a server with multiple advertised methods - you can give it an argument and tell it which one to use. There are at least three ways to "fix" this bug: 1) Convince Mark Crispin (c-client's author) to modify c-client so that it tries all the advertised authentication methods. I.e. proclaim that it's not a PHP bug, that instead the library should be changed to work with imap_open's flaws. 2) Add an argument/flag/option to imap_open so that the programmer can specify the authentication method to try. I.e. Give the PHP developer access to more of the working functionality of the underlying library. 3) Modify PHP's imap_open() so that it will try multiple authentication methods. I understand that deciding that #1 is the "right answer" carries with it the additional benefit that no one needs to admit that this is a PHP bug. However, it's a bit ridiculous considering all of the other applications which depend on c-client and can handle authenticating to these servers. Please review like-minded comments from at least 5 other persons on this bug. I whole-heartedly encourage the maintainer to re-designate this as a real bug.It sounds like the patch was not applied then. It clearly takes 3 or 6 parameters: + if (zend_parse_parameters(argc TSRMLS_CC, "sss|lla", &mailbox, &mailbox_len, &user, &user_len, + &passwd, &passwd_len, &flags, &retries, ¶ms) == FAILURE) { Can you verify that the patch was actually applied?It looks like you may have forgotten to add the following to your patch: Index: php_imap.c =================================================================== --- php_imap.c (revision 3434) +++ php_imap.c (working copy) @@ -105,6 +105,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3) ZEND_ARG_INFO(0, mailbox) ZEND_ARG_INFO(0, user) ZEND_ARG_INFO(0, password) ZEND_ARG_INFO(0, options) ZEND_ARG_INFO(0, n_retries) + ZEND_ARG_INFO(0, params) ZEND_END_ARG_INFO() This should allow for a max of 6 arguments instead of just 5.