It looks like md5secrets can't be used with FreePBX. This doesn't appear to be a feature request, because many devices (and security aware administrators) want encrypted passwords. I've modified 2.3 to include this functionality and am including the said code here for you to add into the main trunk, and possibly to IAX devices as well.
What This Hack Does:
- Allow you to specify secret or md5secret for peer
- Allow you to type plaintext secret in md5secret field, and it will run md5sum
What This Hack Doesn't Do:
- Add MD5Secret Ability to IAX Devices
- Work if your asterisk realm is set to something other than "asterisk".
- Allow device passwords longer than 32 characters.
- Display Popup warnings if no passwords are entered
How to enable this on your FreePBX / Asterisk 1.4 Installation:
- Edit the Functions.inc.php in the core modules directory of freepbx
# cd /var/www/admin/modules/core/functions.inc.php
# cp functions.inc.php functions.inc.php.original
# nano functions.inc.php
- Look for the function named "core_Devices_addsip" and replace it with the following:
//add to sip table
function core_devices_addsip($account) {
global $db;
global $currentFile;
foreach ($_REQUEST as $req=>$data) {
if ( substr($req, 0, 8) == 'devinfo_' ) {
$keyword = substr($req, 8);
if ( $keyword == 'dial' && $data == '' ) {
$sipfields[] = array($account, $keyword, 'SIP/'.$account);
} elseif ($keyword == 'mailbox' && $data == '') {
$sipfields[] = array($account,'mailbox',$account.'@device');
} elseif ($keyword == 'md5secret' && $data != '') {
$sipfields[] = array($account, 'md5secret', md5($account.':asterisk:'.$data));
} else {
$sipfields[] = array($account, $keyword, $data);
}
}
}
- Directly following the "core_devices_addsip" function, is the sipfields array. Replace it with the following piece of code:
if ( !is_array($sipfields) ) { // left for compatibilty....lord knows why !
$sipfields = array(
//array($account,'account',$account),
array($account,'accountcode',(isset($_REQUEST['accountcode']))?$_REQUEST['accountcode']:''),
array($account,'secret',(isset($_REQUEST['secret']))?$_REQUEST['secret']:''),
array($account,'md5secret', (isset($_REQUEST['md5secret']))? $_REQUEST['md5secret']:''),
array($account,'canreinvite',(isset($_REQUEST['canreinvite']))?$_REQUEST['canreinvite']:'no'),
array($account,'context',(isset($_REQUEST['context']))?$_REQUEST['context']:'from-internal'),
array($account,'dtmfmode',(isset($_REQUEST['dtmfmode']))?$_REQUEST['dtmfmode']:''),
array($account,'host',(isset($_REQUEST['host']))?$_REQUEST['host']:'dynamic'),
array($account,'type',(isset($_REQUEST['type']))?$_REQUEST['type']:'friend'),
array($account,'mailbox',(isset($_REQUEST['mailbox']) && !empty($_REQUEST['mailbox']))?$_REQUEST['mailbox']:$account.'@device'),
array($account,'username',(isset($_REQUEST['username']))?$_REQUEST['username']:$account),
array($account,'nat',(isset($_REQUEST['nat']))?$_REQUEST['nat']:'yes'),
array($account,'port',(isset($_REQUEST['port']))?$_REQUEST['port']:'5060'),
array($account,'qualify',(isset($_REQUEST['qualify']))?$_REQUEST['qualify']:'yes'),
array($account,'callgroup',(isset($_REQUEST['callgroup']))?$_REQUEST['callgroup']:''),
array($account,'pickupgroup',(isset($_REQUEST['pickupgroup']))?$_REQUEST['pickupgroup']:''),
array($account,'disallow',(isset($_REQUEST['disallow']))?$_REQUEST['disallow']:''),
array($account,'allow',(isset($_REQUEST['allow']))?$_REQUEST['allow']:'')
//array($account,'record_in',(isset($_REQUEST['record_in']))?$_REQUEST['record_in']:'On-Demand'),
//array($account,'record_out',(isset($_REQUEST['record_out']))?$_REQUEST['record_out']:'On-Demand'),
//array($account,'callerid',(isset($_REQUEST['description']))?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>')
);
}
- Look for the SIP Temporary Arrays, around line 2973 and add this value. We're not sure if it's required, but it works with it here so we left it.
$tmparr['md5secret'] = array('value' => '', 'level' => 0);
- Exit and save the file
- Refresh FreePBX Extension and you should now see md5secret available as an option. This field also appears on the add new sip extension page as well.
Attached is the modified functions.inc.php to diff against the original copy.