我正在与MjSip挣扎,现在我有一个问题,将一个SIP客户端注册到一个SIP注册器(AsteriskNOW发行版:FreePBX + Asterisk + CentOS)。
要执行REGISTER事务,我使用了ExtendedInviteDialog类和ExtendedInviteDialogListener接口,我使用request()发送第一条消息,并使用onDlgAltResponse()检测服务器的答案,最后使用ackWithAnswer()回复。这是onDlgAltResponse的源代码(InviteDialog arg0,String arg1,int code, String arg3,String arg4,Message resp):
if (code==401){
if (resp.hasWwwAuthenticateHeader())
{
nonce = resp.getWwwAuthenticateHeader().getNonceParam();
realm = resp.getWwwAuthenticateHeader().getRealmParam();
AuthorizationHeader ah = new AuthorizationHeader("Digest");
message.setCSeqHeader(message.getCSeqHeader().incSequenceNumber());
ViaHeader vh=message.getViaHeader();
String newbranch = SipProvider.pickBranch();
vh.setBranch(newbranch);
message.removeViaHeader();
message.addViaHeader(vh);
ah.addUsernameParam(username);
ah.addAlgorithParam("MD5");
ah.addRealmParam(realm);
ah.addNonceParam(nonce);
ah.addUriParam(uri);
// String qop_options = resp.getWwwAuthenticateHeader().getQopOptionsParam();
// qop = (qop_options != null) ? "auth" : null;
// ah.addQopParam(qop);
DigestAuthentication x=new DigestAuthentication(resp.getTransactionMethod(),
ah, null, passwd);
String response = x.getResponse();
ah.addResponseParam(response);
if (x.checkResponse()) Log.d("MYSIP","check");
message.setAuthorizationHeader(ah);
arg0.ackWithAnswer(message);
}
}
调试信息:
NOTICE[1595]chan_sip.c27725 handle_request_register : Registration from 'x' failed for 'y' - Wrong password
使用nonce参数和给定密码生成响应后,checkResponse()不返回TRUE!我确信用户名/秘密组合在asterisk的CLI中是正确的。 MD5秘密未激活:秘密仍然以sip.conf中的纯文本形式存储。 这是MD5或服务器扩展的问题吗?我应该手动修改sip.conf文件吗?我需要创建一个SIP干线吗?
答案 0 :(得分:2)
希望这有助于Asterisk 403 Forbidden chan_sip.c:27829错误的密码错误。
我使用FreePBX网站上的一些过时步骤在Linux Mint上设置了我的Asterisk 11.4.0。一切顺利,除了我无法连接所有与Raspberry Pi IncrediblePBX版本一起使用的客户。我不断改变所有想到的东西,使用网络界面和观看可怕的SIP痕迹。
最后我决定在CLI级别检查
sip show users
那里什么也没有,纳达。 FreePBX对一些虚拟配置文件所做的所有更改。我复制了我的数据Asterisk并立即开始工作。
答案 1 :(得分:0)
您需要在扩展名中正确设置nat = yes或nat = no。