<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/2041/1/7/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Secure+Calling+Specifics">Secure Calling Specifics</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~mdavenport">Malcolm Davenport</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">exten =&gt; 123,1,GotoIf(&quot;$[${CHANNEL(secure_signaling)}&quot; = &quot;&quot;]?fail)  <br>exten =&gt; 123,n,GotoIf(&quot;$[${CHANNEL(secure_media)}&quot; = &quot;&quot;]?fail)  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">exten =&gt; 123,1,GotoIf($[&quot;${CHANNEL(secure_signaling)}&quot; = &quot;1&quot;]?:fail)  <br>exten =&gt; 123,n,GotoIf($[&quot;${CHANNEL(secure_media)}&quot; = &quot;1&quot;]?:fail)  <br></td></tr>
            <tr><td class="diff-unchanged" >exten =&gt; 123,n,Dial(SIP/123)  <br>exten =&gt; 123,n,Hangup  <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>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.</p>

<h3><a name="SecureCallingSpecifics-Channelspecificconfiguration"></a>Channel-specific configuration</h3>

<p>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. </p>

<p>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).</p>

<h3><a name="SecureCallingSpecifics-Securitybaseddialplanbranching"></a>Security-based dialplan branching</h3>

<p>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.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
exten =&gt; 123,1,GotoIf($["${CHANNEL(secure_signaling)}" = "1"]?:fail) 
exten =&gt; 123,n,GotoIf($["${CHANNEL(secure_media)}" = "1"]?:fail) 
exten =&gt; 123,n,Dial(SIP/123) 
exten =&gt; 123,n,Hangup 
exten =&gt; 123,n(fail),Playback(vm-goodbye) 
exten =&gt; 123,n,Hangup
]]></script>
</div></div>

<h3><a name="SecureCallingSpecifics-Forcingbridgedchannelstobesecure"></a>Forcing bridged channels to be secure</h3>

<p>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:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: java; gutter: false"><![CDATA[
exten =&gt; 123,1,NoOp(We got a call) 
exten =&gt; 123,n,Set(CHANNEL(secure_bridge_signaling)=1) 
exten =&gt; 123,n,Set(CHANNEL(secure_bridge_media)=1) 
exten =&gt; 123,n,Dial(SIP/somebody) 
exten =&gt; 123,n,NoOp(HANGUPCAUSE=${HANGUPCAUSE}) 
exten =&gt; 123,n,GotoIf($["${HANGUPCAUSE}"="58"]?encrypt_fail) 
exten =&gt; 123,n,Hangup ; notify user that retrying via insecure channel (user-provided prompt) 
exten =&gt; 123,n(encrypt_fail),Playback(secure-call-fail-retry) 
exten =&gt; 123,n,Set(CHANNEL(secure_bridge_signaling)=0) 
exten =&gt; 123,n,Set(CHANNEL(secure_bridge_media)=0) 
exten =&gt; 123,n,Dial(SIP/somebody) 
exten =&gt; 123,n,Hangup
]]></script>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Secure+Calling+Specifics">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=5243090&revisedVersion=5&originalVersion=4">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Secure+Calling+Specifics?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>