Skip to content

Error: "Can't find nonce in www-auth" -cause regex defined not correctly #12

@Carsak

Description

@Carsak

I cant auth to sip server, cause class PhpSip cant parse "nonce"

in code we have line
line if (!preg_match('/^WWW-Authenticate: .* nonce="(.*)"/imU',$this->rx_msg, $m))

But I got this string in rx_msg

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.56.1:52619;rport=52619;received=192.168.56.1;branch=z9hG4bK400475
Call-ID: bd83da2e3b1bea8bd05a0d4f86a95651@192.168.56.1
From: <sip:demo-bob@192.168.56.1>;tag=29476
To: <sip:demo-bob@192.168.56.101>;tag=z9hG4bK400475
CSeq: 20 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1674462773/ed4af0596a23a091b977b82551037698",opaque="5c230e6a1b3ca71a",algorithm=MD5,qop="auth"
Server: Asterisk PBX 20.1.0
Content-Length:  0

So the regexp pattern must be /.*WWW-Authenticate: .* nonce="(.*)"/imU
not /^WWW-Authenticate: .* nonce="(.*)"/imU

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions