title: Failure of SIP Proxy Authentication
body: <p>I'm developing a SIP user agent application that connects to an Asterisk server and tries to do an outgoing call. I'm using the NIST implementation of the JAIN SIP API.</p>
  
  <p>The application first registers itself successfully. Then, when the application transmits an INVITE request to an X-Lite SIP soft phone, Asterisk responds with a 407 (Proxy Authentication Required) response. The response contains a Proxy-Authenticate header. My application sends an INVITE again, but this time with the Proxy-Authorization header, upon which Asterisk responds with 488 (Not acceptable here).</p>
  
  <p>Here follows the SIP conversation ('>>' indicates outgoing messages; '&lt;&lt;' indicates incoming messages):</p>
  
  <blockquote>
    <p><code>&gt;&gt; REGISTER sip:10.0.84.30:5060 SIP/2.0<br>
    Call-ID: 7f2d15884ab375fc7b5d32fdd28426d5@10.0.85.3<br>
    CSeq: 1 REGISTER<br>
    From: &lt;sip:301@asterisk&gt;;tag=0vmZig<br>
    To: &lt;sip:301@asterisk&gt;<br>
    Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835
    Max-Forwards: 70<br>
    Contact: &lt;sip:10.0.85.3:5060&gt;<br>
    Expires: 300<br>
    Content-Length: 0</code></p>
  </blockquote>
  
  <p><code>&lt;&lt; SIP/2.0 100 Trying<br>
  Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835;received=10.0.85.3<br>
  From: &lt;sip:301@asterisk&gt;;tag=0vmZig<br>
  To: &lt;sip:301@asterisk&gt;<br>
  Call-ID: 7f2d15884ab375fc7b5d32fdd28426d5@10.0.85.3<br>
  CSeq: 1 REGISTER<br>
  User-Agent: Asterisk PBX (switchvox)<br>
  Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY<br>
  Contact: &lt;sip:301@10.0.84.30&gt;<br>
  Content-Length: 0</code></p>
  
  <p><code>&lt;&lt; SIP/2.0 401 Unauthorized<br>
  Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK493cd4b63090dc9a8027931937b737c9353835;received=10.0.85.3<br>
  From: &lt;sip:301@asterisk&gt;;tag=0vmZig<br>
  To: &lt;sip:301@asterisk&gt;;tag=as4d134cc6<br>
  Call-ID: 7f2d15884ab375fc7b5d32fdd28426d5@10.0.85.3<br>
  CSeq: 1 REGISTER<br>
  User-Agent: Asterisk PBX (switchvox)<br>
  Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY<br>
  Contact: &lt;sip:301@10.0.84.30&gt;<br>
  WWW-Authenticate: Digest realm="asterisk",nonce="27ca4a51"<br>
  Content-Length:0</code></p>
  
  <blockquote>
    <p><code>&gt;&gt; REGISTER sip:10.0.84.30:5060 SIP/2.0<br>
    CSeq: 2 REGISTER<br>
    From: &lt;sip:301@asterisk&gt;;tag=0vmZig<br>
    To: &lt;sip:301@asterisk&gt;<br>
    Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835
    Max-Forwards: 70<br>
    Contact: &lt;sip:10.0.85.3:5060&gt;<br>
    Expires: 300<br>
    Authorization: Digest username="301",realm="asterisk",nonce="27ca4a51",response="cfdcdff7ddee99d10c3099e88ffb73af",algorithm=MD5,uri="sip:10.0.84.30:5060",nc=00000001<br>
    Call-ID: 7f2d15884ab375fc7b5d32fdd28426d5@10.0.85.3<br>
    Content-Length: 0</code></p>
  </blockquote>
  
  <p><code>&lt;&lt; SIP/2.0 100 Trying<br>
  Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835;received=10.0.85.3<br>
  From: &lt;sip:301@asterisk&gt;;tag=0vmZig<br>
  To: &lt;sip:301@asterisk&gt;<br>
  Call-ID: 7f2d15884ab375fc7b5d32fdd28426d5@10.0.85.3<br>
  CSeq: 2 REGISTER<br>
  User-Agent: Asterisk PBX (switchvox)<br>
  Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY<br>
  Contact: &lt;sip:301@10.0.84.30&gt;<br>
  Content-Length: 0</code></p>
  
  <p><code>&lt;&lt; SIP/2.0 200 OK<br>
  Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bKe339b4ed9edc5d75379673b6dec7fc42353835;received=10.0.85.3<br>
  From: &lt;sip:301@asterisk&gt;;tag=0vmZig<br>
  To: &lt;sip:301@asterisk&gt;;tag=as4d134cc6<br>
  Call-ID: 7f2d15884ab375fc7b5d32fdd28426d5@10.0.85.3<br>
  CSeq: 2 REGISTER<br>
  User-Agent: Asterisk PBX (switchvox)<br>
  Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY<br>
  Expires: 300<br>
  Contact: &lt;sip:10.0.85.3:5060&gt;;expires=300<br>
  Date: Tue, 03 May 2011 09:37:45 GMT<br>
  Content-Length: 0</code></p>
  
  <blockquote>
    <p><code>&gt;&gt; INVITE sip:302@asterisk SIP/2.0<br>
    Call-ID: 003d85b0d0868f6f2a2d8c324d7f1d54@10.0.85.3<br>
    CSeq: 3 INVITE<br>
    From: &lt;sip:301@asterisk&gt;;tag=sJSeLA<br>
    To: &lt;sip:302@asterisk&gt;<br>
    Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6704cd9554c0c8e5bc94bc42b606147a353835
    Max-Forwards: 70<br>
    Contact: &lt;sip:10.0.85.3:5060&gt;<br>
    Route: &lt;sip:10.0.84.30:5060;lr&gt;<br>
    Content-Type: application/sdp<br>
    Content-Length: 106</code></p>
    
    <p><code>v=0<br>
    o=- 3513403599 3513403599 IN IP4 10.0.85.3<br>
    s=-<br>
    c=IN IP4 10.0.85.3<br>
    t=0 0<br>
    m=audio 40000 RTP/AVP 3</code></p>
  </blockquote>
  
  <p><code>&lt;&lt; SIP/2.0 407 Proxy Authentication Required<br>
  Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6704cd9554c0c8e5bc94bc42b606147a353835;received=10.0.85.3<br>
  From: &lt;sip:301@asterisk&gt;;tag=sJSeLA<br>
  To: &lt;sip:302@asterisk&gt;;tag=as7358e1b8<br>
  Call-ID: 003d85b0d0868f6f2a2d8c324d7f1d54@10.0.85.3<br>
  CSeq: 3 INVITE<br>
  User-Agent: Asterisk PBX (switchvox)<br>
  Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY<br>
  Contact: &lt;sip:302@10.0.84.30&gt;<br>
  Proxy-Authenticate: Digest realm="asterisk",nonce="55deefb6"<br>
  Content-Length: 0</code></p>
  
  <blockquote>
    <p><code>&gt;&gt; INVITE sip:302@asterisk SIP/2.0<br>
    CSeq: 4 INVITE<br>
    From: &lt;sip:301@asterisk&gt;;tag=sJSeLA<br>
    To: &lt;sip:302@asterisk&gt;<br>
    Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6e3501c0973664fcd7a17affddd23572353835
    Max-Forwards: 70<br>
    Contact: &lt;sip:10.0.85.3:5060&gt;<br>
    Route: &lt;sip:10.0.84.30:5060;lr&gt;<br>
    Content-Type: application/sdp<br>
    Proxy-Authorization: Digest   username="301",realm="asterisk",nonce="55deefb6",response="47e2c7abe625e4a183726e29c035d7e0",algorithm=MD5,uri="sip:302@asterisk",nc=00000001<br>
    Call-ID: 003d85b0d0868f6f2a2d8c324d7f1d54@10.0.85.3<br>
    Content-Length: 106</code></p>
    
    <p><code>v=0<br>
    o=- 3513403599 3513403599 IN IP4 10.0.85.3<br>
    s=-<br>
    c=IN IP4 10.0.85.3<br>
    t=0 0<br>
    m=audio 40000 RTP/AVP 3</code></p>
  </blockquote>
  
  <p><code>&lt;&lt; SIP/2.0 488 Not acceptable here<br>
  Via: SIP/2.0/UDP 10.0.85.3:5060;branch=z9hG4bK6e3501c0973664fcd7a17affddd23572353835;received=10.0.85.3<br>
  From: &lt;sip:301@asterisk&gt;;tag=sJSeLA<br>
  To: &lt;sip:302@asterisk&gt;;tag=as7358e1b8<br>
  Call-ID: 003d85b0d0868f6f2a2d8c324d7f1d54@10.0.85.3<br>
  CSeq: 4 INVITE<br>
  User-Agent: Asterisk PBX (switchvox)<br>
  Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY<br>
  Contact: &lt;sip:302@10.0.84.30&gt;<br>
  Content-Length: 0</code></p>
  
  <p>What am I doing wrong here, causing the 488 response?</p>