Documentation

Documentation.TipsFAQ History

Hide minor edits - Show changes to markup

May 27, 2013, at 07:25 PM by 109.99.235.212 -
Changed line 1 from:
to:
Documentation -> Tips and FAQ
Deleted line 5:

May 09, 2013, at 01:41 PM by 79.118.227.150 -
Changed line 1 from:

Resources -> Documentation -> Tips and FAQa

to:
April 24, 2013, at 06:07 PM by 213.233.101.41 -
Added lines 1-73:

Resources -> Documentation -> Tips and FAQa


(:toc-float Table of Content:)


Tips

How to do certain things.

How to recalculate ha1 and ha1b

When you change the domain column in the subscriber table, you have to recalculate ha1 and ha1b fields. In order to do that you must have the password of each subscriber. It is stored in the 'password' column if you have set STORE_PLAINTEXT_PW=1 in opensipsctlrc (default).

HA1 is a MD5 hash of "username:domain:password". For example, if you have created a SIP account 1000@mydomain.com using password 123456, then HA1 is the MD5 hash of "1000:mydomain.com:123456" (without quotes). On the other hand HA1B is the MD5 hash of "username@domain:domain:password"; so using the same example above, HA1B would be the MD5 hash of "1000@mydomain.com:mydomain.com:123456" (without quotes).

To recalculate and update ha1 and ha1b columns in the subscriber table, just execute the following sql statement in mysql:

update subscriber
set ha1 = md5(concat(username, ':', domain, ':', password)),
ha1b = md5(concat(username, '@', domain, ':', domain, ':', password))

Note: the above is only true if you have "use_domain" enabled for auth_db _and_ you do not use a static challenge parameter for www_authorize.

If you use a static challenge for www_authorize (i.e. the first parameter of www_authorize is not the empty string), then HA1 is MD5("username:challenge:password") and HA1B is MD5("username@challenge:challenge:password"). If the challenge parameter of www_authorize is empty, OpenSIPS automatically selects the domain as the challenge value, which gives the solution presented above.

If "use_domain" is false, then the HA1B field must be computed based on "username@:domain:password" or "username@:challenge:password", depending on whether challenge is empty or defined, respectively.

PHP example to communicate via mi_xmlrpc
#!/usr/bin/php
<?php
$params[] = "dialog:";
$params[] = "tm:";
$method = "get_statistics";
$request = xmlrpc_encode_request($method,$params);

$context = stream_context_create(array('http' => array(
   'method' => "POST",
   'header' => "Content-Type: text/xml",
   'content' => $request
)));
$file = file_get_contents("http://example.opensips.org:8080/RPC2", false, $context);
$response = xmlrpc_decode($file);
if (is_array($response)) {
   trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
   print_r($response);
}
?>
Add a new tip here

FAQS

Answers to the most frequent questions

Changing FROM header

Q) How does one change the FROM Header in OpenSIPS ?

A) Use the uac_replace_from() function in the uac module

Recalculating HA1 and HA1B hashes when adding a subscriber

Q) How do I re-calculate the ha1 and halb values in the subscriber table for a new subscriber?

A) Run the following mysql operation:

update subscriber set ha1 = md5(concat(username, ':', domain, ':', password)), ha1b = md5(concat(username, '@', domain, ':', domain, ':', password))

This will automatically update the ha1 and ha1b fields for all subscribers.


Page last modified on May 27, 2013, at 07:25 PM