# Asterisk Project : Secure Calling Specifics

Added by mdavenport , edited by mdavenport on Mar 15, 2011

Asterisk supports a channel-agnostic method for handling secure call requirements. Since there is no single meaning of what constitutes a "secure call," Asterisk allows the administrator the control to define "secure" for themselves via the dialplan and channel-specific configuration files.

### Channel-specific configuration

Currently the IAX2 and SIP channels support the call security features in Asterisk. Both channel-specific configuration files (iax2.conf and sip.conf) support the encryption=yes setting. For IAX2, this setting causes Asterisk to offer encryption when placing or receiving a call. To force encryption with IAX2, the forceencrypt=yes option is required. Due to limitations of SDP, encryption=yes in sip.conf results in a call with only a secure media offer, therefor forceencrypt=yes would be redundant in sip.conf.

If a peer is defined as requiring encryption but the endpoint does not support it, the call will fail with a HANGUPCAUSE of 58 (bearer capability does not exist).

### Security-based dialplan branching

Each channel that supports secure signaling or media can implement a CHANNEL read callback function that specifies whether or not that channel meets the specified criteria. Currently, chan_iax2 and chan_sip implement these callbacks. Channels that do not support secure media or signaling will return an empty string when queried. For example, to only allow an inbound call that has both secure signaling and media, see the following example.

    exten => 123,1,GotoIf($["${CHANNEL(secure_signaling)}" = "1"]?:fail)
    exten => 123,n,GotoIf($["${CHANNEL(secure_media)}" = "1"]?:fail)
    exten => 123,n,Dial(SIP/123)
    exten => 123,n,Hangup
    exten => 123,n(fail),Playback(vm-goodbye)
    exten => 123,n,Hangup

### Forcing bridged channels to be secure

Administrators can force outbound channels that are to be bridged to a calling channel to conform to secure media and signaling policies. For example, to first make a call attempt that has both secure signaling and media, but gracefully fall back to non-secure signaling and media see the following example:

    exten => 123,1,NoOp(We got a call)
    exten => 123,n,Set(CHANNEL(secure_bridge_signaling)=1)
    exten => 123,n,Set(CHANNEL(secure_bridge_media)=1)
    exten => 123,n,Dial(SIP/somebody)
    exten => 123,n,NoOp(HANGUPCAUSE=${HANGUPCAUSE})
    exten => 123,n,GotoIf($["${HANGUPCAUSE}"="58"]?encrypt_fail)
    exten => 123,n,Hangup ; notify user that retrying via insecure channel (user-provided prompt)
    exten => 123,n(encrypt_fail),Playback(secure-call-fail-retry)
    exten => 123,n,Set(CHANNEL(secure_bridge_signaling)=0)
    exten => 123,n,Set(CHANNEL(secure_bridge_media)=0)
    exten => 123,n,Dial(SIP/somebody)
    exten => 123,n,Hangup

## Comments:

typo error: seucre => secure
    exten => 123,n,GotoIf("$[${CHANNEL(secure_media)}" = ""]?fail)
Posted by gilles at Jan 28, 2011 02:59
Got it, thanks Posted by mdavenport at Jan 28, 2011 08:07