Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mac OS Keychain with SMTP

107 views
Skip to first unread message

Paul Rankin

unread,
Nov 25, 2014, 12:15:41 AM11/25/14
to help-gn...@gnu.org
Hello,

I'd like to eschew an .authinfo file in favour of the Mac OS Keychain
but can't seem to get it going. I keep receiving the error:

auth-source-macos-keychain-search: The MacOS Keychain auth-source
backend doesn't support creation yet

Some relevant excerpts from my init file:

'(auth-sources (quote (macos-keychain-internet macos-keychain-generic)))
'(smtpmail-smtp-server "mail.example.com")
'(smtpmail-smtp-service 465)
'(smtpmail-smtp-user "us...@example.com")
'(smtpmail-stream-type (quote ssl))
'(send-mail-function (quote smtpmail-send-it))

I have created an entry with Keychain Access in my default keychain with
the following:

Keychain Item Name: mail.example.com
Account Name: us...@example.com
Password: password12345

The following commands return the password:

$ security find-generic-password -l mail.example.com -a us...@example.com -w
=> password12345
$ security find-generic-password -s mail.example.com -a us...@example.com -w
=> password12345

However, if I eval

(auth-source-search :label "mail.example.com")
=> nil
(auth-source-search :server "mail.example.com")
= nil
(auth-source-search :label "mail.example.com" :user "us...@example.com")
=> nil

The Mac OS authorisation popup appears, but I can't tell whether it's
returning the password...

I have the `security` retrieval method working for OfflineIMAP using the
real Keychain entry, so it's not a user/password problem.

I'm happy to switch to another `send-mail-function`. If anyone has
working SMTP email with Mac OS Keychain auth I would love some pointers :)

Many thanks,

--
Paul W. Rankin
http://www.paulwrankin.com

Before printing this email please take a moment to think about the
environment. Just stop and think about it. Think about the last time you
were walking alone in a forest, how you felt at peace, how a wave of
clarity seemed to overcome you and you had to stop and reevaluate your
life, what you're doing with the limited time you have here. "Damn," you
thought, "life is so precious. I should really be doing ______." Are you
doing that now? Why not? Go on, pick up your computer and throw it out
the window! It'll be great, like that scene from Network where everyone
starts yelling "I'M MAD AS HELL AND I'M NOT GOING TO TAKE THIS ANY
MORE." That'll be you, but it will be real. Now's your moment.

Ted Zlatanov

unread,
Nov 25, 2014, 4:57:33 AM11/25/14
to
On Tue, 25 Nov 2014 15:15:15 +1000 Paul Rankin <pa...@tilk.co> wrote:

PR> I'd like to eschew an .authinfo file in favour of the Mac OS Keychain
PR> but can't seem to get it going. I keep receiving the error:

PR> auth-source-macos-keychain-search: The MacOS Keychain auth-source
PR> backend doesn't support creation yet

Please see Emacs bug#19074: Bug in auth-source.el's search of OS X
Keychain at https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-11/msg00805.html

There's a patch there which I haven't been able to test. If you could,
please try it and let me know your experience (in the bug thread or
here). You will have to pre-create your security tokens in the Mac
OS X, since creating them through auth-source.el is not supported yet.

Thanks
Ted

Paul Rankin

unread,
Nov 26, 2014, 1:46:06 AM11/26/14
to Ted Zlatanov, help-gn...@gnu.org
I applied the patch and can now successfully use SMTP with a password
without an .authinfo file.

One further problem I had was that `auth-source.el` seems to always
query `security` with a port number, and I hadn't added a port number to
the keychain item in question, so, in Keychain Access.app

Where: smtp://mail.example.com:465

fixed the problem.

This is probably a silly question, but if I don't want to mess with my
Emacs distribution, I should just put the patched version of
`auth-source-macos-keychain-search-items` into my init file right?

Ted Zlatanov

unread,
Nov 26, 2014, 9:07:46 AM11/26/14
to
On Wed, 26 Nov 2014 15:56:26 +1000 Paul Rankin <pa...@tilk.co> wrote:

PR> Ted Zlatanov <t...@lifelogs.com> writes:

>> On Tue, 25 Nov 2014 15:15:15 +1000 Paul Rankin <pa...@tilk.co> wrote:
>>
PR> I'd like to eschew an .authinfo file in favour of the Mac OS Keychain
PR> but can't seem to get it going. I keep receiving the error:
>>
PR> auth-source-macos-keychain-search: The MacOS Keychain auth-source
PR> backend doesn't support creation yet
>>
>> Please see Emacs bug#19074: Bug in auth-source.el's search of OS X
>> Keychain at https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-11/msg00805.html
>>
>> There's a patch there which I haven't been able to test. If you could,
>> please try it and let me know your experience (in the bug thread or
>> here). You will have to pre-create your security tokens in the Mac
>> OS X, since creating them through auth-source.el is not supported yet.

PR> I applied the patch and can now successfully use SMTP with a password
PR> without an .authinfo file.

Cool. Would you like to update the auth.texi manual to help fellow Mac
OS X users with some guidelines and the note below?

PR> One further problem I had was that `auth-source.el` seems to always
PR> query `security` with a port number, and I hadn't added a port number to
PR> the keychain item in question, so, in Keychain Access.app

PR> Where: smtp://mail.example.com:465

PR> fixed the problem.

Great!

PR> This is probably a silly question, but if I don't want to mess with my
PR> Emacs distribution, I should just put the patched version of
PR> `auth-source-macos-keychain-search-items` into my init file right?

Yes, temporarily. I will apply that patch soon to emacs-24 and it will
get forward-ported to master as well.

Ted

Paul Rankin

unread,
Nov 27, 2014, 10:46:00 PM11/27/14
to Ted Zlatanov, help-gn...@gnu.org

Ted Zlatanov <t...@lifelogs.com> writes:

>>> Please see Emacs bug#19074: Bug in auth-source.el's search of OS X
>>> Keychain at https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-11/msg00805.html
>>>
>>> There's a patch there which I haven't been able to test. If you could,
>>> please try it and let me know your experience (in the bug thread or
>>> here). You will have to pre-create your security tokens in the Mac
>>> OS X, since creating them through auth-source.el is not supported yet.
>
> PR> I applied the patch and can now successfully use SMTP with a password
> PR> without an .authinfo file.
>
> Cool. Would you like to update the auth.texi manual to help fellow Mac
> OS X users with some guidelines and the note below?
>
> PR> One further problem I had was that `auth-source.el` seems to always
> PR> query `security` with a port number, and I hadn't added a port number to
> PR> the keychain item in question, so, in Keychain Access.app
>
> PR> Where: smtp://mail.example.com:465
>
> PR> fixed the problem.
>
> Great!

I have perhaps found a related bug.

When:

'(auth-sources (quote (macos-keychain-internet)))

and attempting to join a channel in erc, then I get the looping error:

error in process filter: erc-channel-receive-names: Wrong type argument: hash-table-p, nil
error in process filter: Wrong type argument: hash-table-p, nil

When:

'(auth-sources (quote ("~/.authinfo" macos-keychain-internet)))

then everything works as expected.

Paul Rankin

unread,
Nov 27, 2014, 11:13:49 PM11/27/14
to Ted Zlatanov, help-gn...@gnu.org

Paul Rankin <pa...@tilk.co> writes:

> I have perhaps found a related bug.
>
> When:
>
> '(auth-sources (quote (macos-keychain-internet)))
>
> and attempting to join a channel in erc, then I get the looping error:
>
> error in process filter: erc-channel-receive-names: Wrong type argument: hash-table-p, nil
> error in process filter: Wrong type argument: hash-table-p, nil
>
> When:
>
> '(auth-sources (quote ("~/.authinfo" macos-keychain-internet)))
>
> then everything works as expected.

p.s. In above I do not have a ~/.authinfo file in either case.
0 new messages