03
2019
04
12:59:22

Asterisk的SIP type和身份认证



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

在Asterisk中对某个peer的类型分为3种:peer, user和friend

看看voip-info对这三种类型的解释


peer : A SIP entity to which Asterisk sends calls (a SIP provider for example). If you want a user (extension) to have multiple phones, define an extension that calls two SIP peers. The peer authenticates at registration.

user : A SIP entity which places calls through Asterisk (A phone which can place calls only). Users authenticate to reach services with their context.

friend : An entity which is both a user and a peer. This make sense for most desk handsets and other devices. Asterisk will create two objects, one peer and one user, with the same name.

If a _peer_ is defined with host=dynamic  it is allowed to register  with Asterisk to tell Asterisk where it can be found (IP address/host name) and that it is reachable from now on. 


简单的说,在这篇文档里, type=peer定义对方是一个服务提供者, 它允许你的Asterisk通过这里定义的服务商打电话; 而user则定义对方是你的一个客户端, 允许对方通过你的Asterisk打电话. friend就是两者兼有.


但是实际情况是什么? 试试这样的定义:

[1001]

username=1001

secret=xxxxx

host=dynamic

port=5060

type=peer

context=from-extensions


然后用一个SIP客户端来尝试注册到你的Asterisk上, what happened?

你会发现客户端也能注册上!


其实type的真正意义在于Asterisk怎么去处理发往外部和来自外部的请求.

type=peer 

如果type是peer,有两层含义.

1. 可以将对方作为一个SIP Service Provider, 允许你的Asterisk通过对方进行呼出.

2. 如果对方在逻辑上是一个客户端, asterisk将根据传入的Invite请求来对对方进行身份验证, 但需要注意的是这里的验证不是通过username和secret, 而是通过对方的address和port. 这里分两种情况:

* 对方的address和port没有匹配到你在sip.conf中对任何一个peer的设置, 如果你的Asterisk允许匿名呼入(allowguest=yes), 那么, 该呼入将被传到在sip.conf的general配置中的context上. 如果不允许匿名呼入, 直接拒绝该呼入.

* 对方的address和port匹配到了任何一个sip.conf种的peer设置, 那么改呼入将被传到该peer指定的context上.

Asterisk还提供了一个insecure参数来配置对peer呼入的身份验证方式.

insecure=port|invite

    port: Asterisk忽略对方的port, 只根据对方的address来验证某个peer, Asterisk收到对方的Invite后, 会发送SIP/2.0 401 Unauthorized到对方, 要求对方发送认证信息, 但事实上对方返回回来的认证信息不会被真正使用.

    invite: Asterisk对初始Invite不进行验证. 这意味着Asterisk直接使用客户端传入的Invite包中的信息尝试进行验证而不会发送SIP/2.0 401 Unauthorized包到对方


type=user 

根据来源Invite包中的用户和密码信息来认证,所以对方不能也不需要Register到你的Asterisk服务器上.


需要额外说明一点的是Register, 如果某个peer的host设置为dynamic, 那么Asterisk允许客户端通过Register的方式来告诉Asterisk对方的地址和端口.


 

--------------------- 

作者:softdog 

来源:CSDN 

原文:https://blog.csdn.net/softdog/article/details/5614138 

版权声明:本文为博主原创文章,转载请附上博文链接!


本文链接:https://hqyman.cn/post/473.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: