top of page

Integration of Stir/Shaken into Asterisk

Updated: Dec 26, 2022

As deadlines for Stir/Shaken are just around the corner even other countries are considering to introduce Stir/Shaken or similar methods.


As we offer a broad range of Fraud Mitigation and Stir/Shaken APIs you can find below an example macro for Asterisk to integrate CodeB’s Stir/Shaken API.


Note: Please do not forget to replace the string “YOUR_API_KEY” with your real CodeB API Key. If you need an evaluation key kindly request one from info@codeb.io


Integration is easy. Just add the following lines into the file /etc/asterisk/extensions_custom.conf on your asterisk server:


[macro-dialout-trunk-predial-hook] ; history 2021-07-10 first commit ; marco requires recent Asterisk versions 16/18/19 or higher


exten => s,1,Noop(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)


; setup curlopts and curl API call with call params exten => s,n,Set(CURLOPT(httptimeout)=20) ; do not try longer than 20 seconds exten => s,n,Set(CURLOPT(httpheader)=x-api-key: YOUR_API_KEY) exten => s,n,Set(CURLOPT(httpheader)=Content-Type: application/json) exten => s,n,Set(response=${CURL(https://testauth.cban.net/sign/shaken?Attestation=A&ToNumber=${OUTNUM}&FromNumber=${CALLERID(num)})})


; check if CodeB delivered and skip to end if not exten => s,n,GotoIf($[“${JSON_DECODE(response,Identity)}”=””]?finish) exten => s,n,Set(IdentityHeader=${JSON_DECODE(response,Identity)}) exten => s,n,GoSub(func-set-sipheader,s,1(Identity,${IdentityHeader}))

exten => s,n(finish),MacroExit()


; end macro-dialout-trunk-predial-hook


Recent Posts

See All
CLI Spoofing / OBR Fraud

Increasing numbers of mobile operators within the European economic area have introduced origin based rating (OBR) for voice termination....

 
 

Comments


Commenting on this post isn't available anymore. Contact the site owner for more info.
bottom of page