<!DOCTYPE html PUBLIC "XSLT-compat"> <html lang="en-GB"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="../../../../common.css"> <meta name="author" content="The Exim Project. <http://www.exim.org/>"> <meta name="copyright" content="Copyright ©2010 The Exim Project. All rights reserved"> <meta name="description" content="Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet."> <meta name="keywords" content="exim,smtp,mta,email"> <meta name="robots" content="noodp,noydir,index,follow"> <meta name="viewport" content="width=device-width"> <title>35. The cram_md5 authenticator</title> <link rel="stylesheet" type="text/css" href="../../../../doc/chapter.css"> <link rel="canonical" href="http://www.exim.org/exim-html-current/doc/html/spec_html/ch35.html"> </head> <body> <h1 id="header"><a href="../../../..">Exim Internet Mailer</a></h1> <div id="outer"> <ul id="nav_flow" class="nav"> <li><a href="../../../../index.html">Home</a></li> <li><a href="../../../../mirrors.html">Download</a></li> <li><a href="../../../../docs.html">Documentation</a></li> <li><a href="../../../../maillist.html">Mailing Lists</a></li> <li><a href="http://wiki.exim.org/">Wiki</a></li> <li><a href="http://www.exim.org/bugzilla/">Bugs</a></li> <li><a href="../../../../credits.html">Credits</a></li> <li class="search"><form action="http://www.google.com/search" method="get"> <span class="search_field_container"><input type="search" name="q" placeholder="Search Docs" class="search_field"></span><input type="hidden" name="hl" value="en"><input type="hidden" name="ie" value="UTF-8"><input type="hidden" name="as_qdr" value="all"><input type="hidden" name="q" value="site:www.exim.org"><input type="hidden" name="q" value="inurl:exim-html-current"> </form></li> </ul> <div id="inner"><div id="content"> <a class="previous_page" href="ch34.html"><-previous</a><a class="next_page" href="ch36.html">next-></a><div id="chapter" class="chapter"> <h2 id="CHID9" class="">Chapter 35 - The cram_md5 authenticator</h2> <p> The CRAM-MD5 authentication mechanism is described in RFC 2195. The server sends a challenge string to the client, and the response consists of a user name and the CRAM-MD5 digest of the challenge string combined with a secret string (password) which is known to both server and client. Thus, the secret is not sent over the network as plain text, which makes this authenticator more secure than <span class="docbook_command">plaintext</span>. However, the downside is that the secret has to be available in plain text at either end. </p> <div class="section"> <h3 id="SECID176" class="">1. Using cram_md5 as a server</h3> <p> This authenticator has one server option, which must be set to configure the authenticator as a server: </p> <p> </p> <table> <tr> <td><span class="docbook_option">server_secret</span></td> <td>Use: <span class="docbook_emphasis">cram_md5</span> </td> <td>Type: <span class="docbook_emphasis">string</span>†<span class="docbook_emphasis"></span> </td> <td>Default: <span class="docbook_emphasis">unset</span> </td> </tr> </table> <p> When the server receives the client’s response, the user name is placed in the expansion variable $auth1, and <span class="docbook_option">server_secret</span> is expanded to obtain the password for that user. The server then computes the CRAM-MD5 digest that the client should have sent, and checks that it received the correct string. If the expansion of <span class="docbook_option">server_secret</span> is forced to fail, authentication fails. If the expansion fails for some other reason, a temporary error code is returned to the client. </p> <p> For compatibility with previous releases of Exim, the user name is also placed in $1. However, the use of this variables for this purpose is now deprecated, as it can lead to confusion in string expansions that also use numeric variables for other things. </p> <p> For example, the following authenticator checks that the user name given by the client is “ph10”, and if so, uses “secret” as the password. For any other user name, authentication fails. </p> <div class="docbook_literallayout"><pre> fixed_cram: driver = cram_md5 public_name = CRAM-MD5 server_secret = ${if eq{$auth1}{ph10}{secret}fail} server_set_id = $auth1 </pre></div> <p> If authentication succeeds, the setting of <span class="docbook_option">server_set_id</span> preserves the user name in $authenticated_id. A more typical configuration might look up the secret string in a file, using the user name as the key. For example: </p> <div class="docbook_literallayout"><pre> lookup_cram: driver = cram_md5 public_name = CRAM-MD5 server_secret = ${lookup{$auth1}lsearch{/etc/authpwd}\ {$value}fail} server_set_id = $auth1 </pre></div> <p> Note that this expansion explicitly forces failure if the lookup fails because $auth1 contains an unknown user name. </p> </div> <div class="section"> <h3 id="SECID177" class="">2. Using cram_md5 as a client</h3> <p> When used as a client, the <span class="docbook_command">cram_md5</span> authenticator has two options: </p> <p> </p> <table> <tr> <td><span class="docbook_option">client_name</span></td> <td>Use: <span class="docbook_emphasis">cram_md5</span> </td> <td>Type: <span class="docbook_emphasis">string</span>†<span class="docbook_emphasis"></span> </td> <td>Default: <span class="docbook_emphasis">the primary host name</span> </td> </tr> </table> <p> This string is expanded, and the result used as the user name data when computing the response to the server’s challenge. </p> <p> </p> <table> <tr> <td><span class="docbook_option">client_secret</span></td> <td>Use: <span class="docbook_emphasis">cram_md5</span> </td> <td>Type: <span class="docbook_emphasis">string</span>†<span class="docbook_emphasis"></span> </td> <td>Default: <span class="docbook_emphasis">unset</span> </td> </tr> </table> <p> This option must be set for the authenticator to work as a client. Its value is expanded and the result used as the secret string when computing the response. </p> <p> Different user names and secrets can be used for different servers by referring to $host or $host_address in the options. Forced failure of either expansion string is treated as an indication that this authenticator is not prepared to handle this case. Exim moves on to the next configured client authenticator. Any other expansion failure causes Exim to give up trying to send the message to the current server. </p> <p> A simple example configuration of a <span class="docbook_command">cram_md5</span> authenticator, using fixed strings, is: </p> <div class="docbook_literallayout"><pre> fixed_cram: driver = cram_md5 public_name = CRAM-MD5 client_name = ph10 client_secret = secret </pre></div> <p> </p> </div> </div> <a class="previous_page" href="ch34.html"><-previous</a><a class="next_page" href="ch36.html">next-></a> </div></div> <iframe id="branding" name="branding" src="../../../../branding/branding.html" height="0" frameborder="no" scrolling="no"></iframe><div id="footer">Website design by <a href="https://secure.grepular.com/">Mike Cardwell</a>, of <a href="http://cardwellit.com/">Cardwell IT Ltd.</a> </div> <div class="left_bar"></div> <div class="right_bar"></div> <div id="toc"> <ul class="hidden"></ul> <img src="../../../../doc/contents.png" width="16" height="155"> </div> </div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script><script type="text/javascript" src="../../../../common.js"></script><script type="text/javascript" src="../../../../doc/chapter.js"></script> </body> </html>