mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Added methods to set TLS certificate/key on LinphoneAuthInfo + updated auth_info_requested callback
This commit is contained in:
parent
9aa49cdcc9
commit
f575f94bb4
23 changed files with 494 additions and 142 deletions
|
|
@ -109,7 +109,7 @@ static char **linephonec_readline_completion(const char *text,
|
|||
#endif
|
||||
|
||||
/* These are callback for linphone core */
|
||||
static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
|
||||
static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
|
||||
static void linphonec_display_refer (LinphoneCore * lc, const char *refer_to);
|
||||
static void linphonec_display_something (LinphoneCore * lc, const char *something);
|
||||
static void linphonec_display_url (LinphoneCore * lc, const char *something, const char *url);
|
||||
|
|
@ -249,7 +249,7 @@ linphonec_display_url (LinphoneCore * lc, const char *something, const char *url
|
|||
* Linphone core callback
|
||||
*/
|
||||
static void
|
||||
linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain)
|
||||
linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method)
|
||||
{
|
||||
/* no prompt possible when using pipes or tcp mode*/
|
||||
if (unix_socket){
|
||||
|
|
|
|||
|
|
@ -44,161 +44,226 @@ LinphoneAuthInfo *linphone_auth_info_new(const char *username, const char *useri
|
|||
|
||||
LinphoneAuthInfo *linphone_auth_info_clone(const LinphoneAuthInfo *ai){
|
||||
LinphoneAuthInfo *obj=ms_new0(LinphoneAuthInfo,1);
|
||||
if (ai->username) obj->username=ms_strdup(ai->username);
|
||||
if (ai->userid) obj->userid=ms_strdup(ai->userid);
|
||||
if (ai->passwd) obj->passwd=ms_strdup(ai->passwd);
|
||||
if (ai->ha1) obj->ha1=ms_strdup(ai->ha1);
|
||||
if (ai->realm) obj->realm=ms_strdup(ai->realm);
|
||||
if (ai->domain) obj->domain=ms_strdup(ai->domain);
|
||||
if (ai->username) obj->username = ms_strdup(ai->username);
|
||||
if (ai->userid) obj->userid = ms_strdup(ai->userid);
|
||||
if (ai->passwd) obj->passwd = ms_strdup(ai->passwd);
|
||||
if (ai->ha1) obj->ha1 = ms_strdup(ai->ha1);
|
||||
if (ai->realm) obj->realm = ms_strdup(ai->realm);
|
||||
if (ai->domain) obj->domain = ms_strdup(ai->domain);
|
||||
if (ai->tls_cert) obj->domain = ms_strdup(ai->tls_cert);
|
||||
if (ai->tls_key) obj->domain = ms_strdup(ai->tls_key);
|
||||
if (ai->tls_cert_path) obj->domain = ms_strdup(ai->tls_cert_path);
|
||||
if (ai->tls_key_path) obj->domain = ms_strdup(ai->tls_key_path);
|
||||
return obj;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_username(const LinphoneAuthInfo *i){
|
||||
const char *linphone_auth_info_get_username(const LinphoneAuthInfo *i) {
|
||||
return i->username;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_passwd(const LinphoneAuthInfo *i){
|
||||
const char *linphone_auth_info_get_passwd(const LinphoneAuthInfo *i) {
|
||||
return i->passwd;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_userid(const LinphoneAuthInfo *i){
|
||||
const char *linphone_auth_info_get_userid(const LinphoneAuthInfo *i) {
|
||||
return i->userid;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_realm(const LinphoneAuthInfo *i){
|
||||
const char *linphone_auth_info_get_realm(const LinphoneAuthInfo *i) {
|
||||
return i->realm;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_domain(const LinphoneAuthInfo *i){
|
||||
const char *linphone_auth_info_get_domain(const LinphoneAuthInfo *i) {
|
||||
return i->domain;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_ha1(const LinphoneAuthInfo *i){
|
||||
const char *linphone_auth_info_get_ha1(const LinphoneAuthInfo *i) {
|
||||
return i->ha1;
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd){
|
||||
if (info->passwd!=NULL) {
|
||||
const char *linphone_auth_info_get_tls_cert(const LinphoneAuthInfo *i) {
|
||||
return i->tls_cert;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_tls_key(const LinphoneAuthInfo *i) {
|
||||
return i->tls_key;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_tls_cert_path(const LinphoneAuthInfo *i) {
|
||||
return i->tls_cert_path;
|
||||
}
|
||||
|
||||
const char *linphone_auth_info_get_tls_key_path(const LinphoneAuthInfo *i) {
|
||||
return i->tls_key_path;
|
||||
}
|
||||
|
||||
|
||||
void linphone_auth_info_set_passwd(LinphoneAuthInfo *info, const char *passwd) {
|
||||
if (info->passwd) {
|
||||
ms_free(info->passwd);
|
||||
info->passwd=NULL;
|
||||
info->passwd = NULL;
|
||||
}
|
||||
if (passwd!=NULL && (strlen(passwd)>0)) info->passwd=ms_strdup(passwd);
|
||||
if (passwd && strlen(passwd) > 0) info->passwd = ms_strdup(passwd);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username){
|
||||
if (info->username){
|
||||
void linphone_auth_info_set_username(LinphoneAuthInfo *info, const char *username) {
|
||||
if (info->username) {
|
||||
ms_free(info->username);
|
||||
info->username=NULL;
|
||||
info->username = NULL;
|
||||
}
|
||||
if (username && strlen(username)>0) info->username=ms_strdup(username);
|
||||
if (username && strlen(username) > 0) info->username = ms_strdup(username);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid){
|
||||
if (info->userid){
|
||||
void linphone_auth_info_set_userid(LinphoneAuthInfo *info, const char *userid) {
|
||||
if (info->userid) {
|
||||
ms_free(info->userid);
|
||||
info->userid=NULL;
|
||||
info->userid = NULL;
|
||||
}
|
||||
if (userid && strlen(userid)>0) info->userid=ms_strdup(userid);
|
||||
if (userid && strlen(userid) > 0) info->userid = ms_strdup(userid);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_realm(LinphoneAuthInfo *info, const char *realm){
|
||||
if (info->realm){
|
||||
void linphone_auth_info_set_realm(LinphoneAuthInfo *info, const char *realm) {
|
||||
if (info->realm) {
|
||||
ms_free(info->realm);
|
||||
info->realm=NULL;
|
||||
info->realm = NULL;
|
||||
}
|
||||
if (realm && strlen(realm)>0) info->realm=ms_strdup(realm);
|
||||
if (realm && strlen(realm) > 0) info->realm = ms_strdup(realm);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_domain(LinphoneAuthInfo *info, const char *domain){
|
||||
if (info->domain){
|
||||
void linphone_auth_info_set_domain(LinphoneAuthInfo *info, const char *domain) {
|
||||
if (info->domain) {
|
||||
ms_free(info->domain);
|
||||
info->domain=NULL;
|
||||
info->domain = NULL;
|
||||
}
|
||||
if (domain && strlen(domain)>0) info->domain=ms_strdup(domain);
|
||||
if (domain && strlen(domain) > 0) info->domain = ms_strdup(domain);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_ha1(LinphoneAuthInfo *info, const char *ha1){
|
||||
if (info->ha1){
|
||||
void linphone_auth_info_set_ha1(LinphoneAuthInfo *info, const char *ha1) {
|
||||
if (info->ha1) {
|
||||
ms_free(info->ha1);
|
||||
info->ha1=NULL;
|
||||
info->ha1 = NULL;
|
||||
}
|
||||
if (ha1 && strlen(ha1)>0) info->ha1=ms_strdup(ha1);
|
||||
if (ha1 && strlen(ha1) > 0) info->ha1 = ms_strdup(ha1);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_tls_cert(LinphoneAuthInfo *info, const char *tls_cert) {
|
||||
if (info->tls_cert) {
|
||||
ms_free(info->tls_cert);
|
||||
info->tls_cert = NULL;
|
||||
}
|
||||
if (tls_cert && strlen(tls_cert) > 0) info->tls_cert = ms_strdup(tls_cert);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_tls_key(LinphoneAuthInfo *info, const char *tls_key) {
|
||||
if (info->tls_key) {
|
||||
ms_free(info->tls_key);
|
||||
info->tls_key = NULL;
|
||||
}
|
||||
if (tls_key && strlen(tls_key) > 0) info->tls_key = ms_strdup(tls_key);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_tls_cert_path(LinphoneAuthInfo *info, const char *tls_cert_path) {
|
||||
if (info->tls_cert_path) {
|
||||
ms_free(info->tls_cert_path);
|
||||
info->tls_cert_path = NULL;
|
||||
}
|
||||
if (tls_cert_path && strlen(tls_cert_path) > 0) info->tls_cert_path = ms_strdup(tls_cert_path);
|
||||
}
|
||||
|
||||
void linphone_auth_info_set_tls_key_path(LinphoneAuthInfo *info, const char *tls_key_path) {
|
||||
if (info->tls_key_path) {
|
||||
ms_free(info->tls_key_path);
|
||||
info->tls_key_path = NULL;
|
||||
}
|
||||
if (tls_key_path && strlen(tls_key_path) > 0) info->tls_key_path = ms_strdup(tls_key_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a LinphoneAuthInfo object.
|
||||
**/
|
||||
void linphone_auth_info_destroy(LinphoneAuthInfo *obj){
|
||||
if (obj->username!=NULL) ms_free(obj->username);
|
||||
if (obj->userid!=NULL) ms_free(obj->userid);
|
||||
if (obj->passwd!=NULL) ms_free(obj->passwd);
|
||||
if (obj->ha1!=NULL) ms_free(obj->ha1);
|
||||
if (obj->realm!=NULL) ms_free(obj->realm);
|
||||
if (obj->domain!=NULL) ms_free(obj->domain);
|
||||
if (obj->username != NULL) ms_free(obj->username);
|
||||
if (obj->userid != NULL) ms_free(obj->userid);
|
||||
if (obj->passwd != NULL) ms_free(obj->passwd);
|
||||
if (obj->ha1 != NULL) ms_free(obj->ha1);
|
||||
if (obj->realm != NULL) ms_free(obj->realm);
|
||||
if (obj->domain != NULL) ms_free(obj->domain);
|
||||
if (obj->tls_cert != NULL) ms_free(obj->tls_cert);
|
||||
if (obj->tls_key != NULL) ms_free(obj->tls_key);
|
||||
if (obj->tls_cert_path != NULL) ms_free(obj->tls_cert_path);
|
||||
if (obj->tls_key_path != NULL) ms_free(obj->tls_key_path);
|
||||
ms_free(obj);
|
||||
}
|
||||
|
||||
void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, int pos)
|
||||
{
|
||||
void linphone_auth_info_write_config(LpConfig *config, LinphoneAuthInfo *obj, int pos) {
|
||||
char key[50];
|
||||
bool_t store_ha1_passwd = lp_config_get_int(config, "sip", "store_ha1_passwd", 1);
|
||||
|
||||
sprintf(key, "auth_info_%i", pos);
|
||||
lp_config_clean_section(config, key);
|
||||
|
||||
sprintf(key,"auth_info_%i",pos);
|
||||
lp_config_clean_section(config,key);
|
||||
|
||||
if (obj==NULL || lp_config_get_int(config, "sip", "store_auth_info", 1) == 0){
|
||||
if (obj == NULL || lp_config_get_int(config, "sip", "store_auth_info", 1) == 0) {
|
||||
return;
|
||||
}
|
||||
if (!obj->ha1 && obj->realm && obj->passwd && (obj->username||obj->userid) && store_ha1_passwd) {
|
||||
if (!obj->ha1 && obj->realm && obj->passwd && (obj->username || obj->userid) && store_ha1_passwd) {
|
||||
/*compute ha1 to avoid storing clear text password*/
|
||||
obj->ha1=ms_malloc(33);
|
||||
sal_auth_compute_ha1(obj->userid?obj->userid:obj->username,obj->realm,obj->passwd,obj->ha1);
|
||||
obj->ha1 = ms_malloc(33);
|
||||
sal_auth_compute_ha1(obj->userid ? obj->userid : obj->username, obj->realm, obj->passwd, obj->ha1);
|
||||
}
|
||||
if (obj->username!=NULL){
|
||||
lp_config_set_string(config,key,"username",obj->username);
|
||||
if (obj->username != NULL) {
|
||||
lp_config_set_string(config, key, "username", obj->username);
|
||||
}
|
||||
if (obj->userid!=NULL){
|
||||
lp_config_set_string(config,key,"userid",obj->userid);
|
||||
if (obj->userid != NULL) {
|
||||
lp_config_set_string(config, key, "userid", obj->userid);
|
||||
}
|
||||
if (obj->ha1!=NULL){
|
||||
lp_config_set_string(config,key,"ha1",obj->ha1);
|
||||
if (obj->ha1 != NULL) {
|
||||
lp_config_set_string(config, key, "ha1", obj->ha1);
|
||||
}
|
||||
if (obj->passwd != NULL){
|
||||
if (store_ha1_passwd && obj->ha1){
|
||||
if (obj->passwd != NULL) {
|
||||
if (store_ha1_passwd && obj->ha1) {
|
||||
/*if we have our ha1 and store_ha1_passwd set to TRUE, then drop the clear text password for security*/
|
||||
linphone_auth_info_set_passwd(obj, NULL);
|
||||
}else{
|
||||
} else {
|
||||
/*we store clear text password only if store_ha1_passwd is FALSE AND we have an ha1 to store. Otherwise, passwd would simply be removed, which might bring major auth issue*/
|
||||
lp_config_set_string(config,key,"passwd",obj->passwd);
|
||||
lp_config_set_string(config, key, "passwd", obj->passwd);
|
||||
}
|
||||
}
|
||||
if (obj->realm!=NULL){
|
||||
lp_config_set_string(config,key,"realm",obj->realm);
|
||||
if (obj->realm != NULL) {
|
||||
lp_config_set_string(config, key, "realm", obj->realm);
|
||||
}
|
||||
if (obj->domain!=NULL){
|
||||
lp_config_set_string(config,key,"domain",obj->domain);
|
||||
if (obj->domain != NULL) {
|
||||
lp_config_set_string(config, key, "domain", obj->domain);
|
||||
}
|
||||
if (obj->tls_cert_path != NULL) {
|
||||
lp_config_set_string(config, key, "client_cert_chain", obj->tls_cert_path);
|
||||
}
|
||||
if (obj->tls_key_path != NULL) {
|
||||
lp_config_set_string(config, key, "client_cert_key", obj->tls_key_path);
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int pos)
|
||||
{
|
||||
char key[50];
|
||||
const char *username,*userid,*passwd,*ha1,*realm,*domain;
|
||||
const char *username,*userid,*passwd,*ha1,*realm,*domain,*tls_cert_path,*tls_key_path;
|
||||
LinphoneAuthInfo *ret;
|
||||
|
||||
sprintf(key,"auth_info_%i",pos);
|
||||
if (!lp_config_has_section(config,key)){
|
||||
sprintf(key, "auth_info_%i", pos);
|
||||
if (!lp_config_has_section(config, key)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
username=lp_config_get_string(config,key,"username",NULL);
|
||||
userid=lp_config_get_string(config,key,"userid",NULL);
|
||||
passwd=lp_config_get_string(config,key,"passwd",NULL);
|
||||
ha1=lp_config_get_string(config,key,"ha1",NULL);
|
||||
realm=lp_config_get_string(config,key,"realm",NULL);
|
||||
domain=lp_config_get_string(config,key,"domain",NULL);
|
||||
ret=linphone_auth_info_new(username,userid,passwd,ha1,realm,domain);
|
||||
username = lp_config_get_string(config, key, "username", NULL);
|
||||
userid = lp_config_get_string(config, key, "userid", NULL);
|
||||
passwd = lp_config_get_string(config, key, "passwd", NULL);
|
||||
ha1 = lp_config_get_string(config, key, "ha1", NULL);
|
||||
realm = lp_config_get_string(config, key, "realm", NULL);
|
||||
domain = lp_config_get_string(config, key, "domain", NULL);
|
||||
tls_cert_path = lp_config_get_string(config, key, "client_cert_chain", NULL);
|
||||
tls_key_path = lp_config_get_string(config, key, "client_cert_key", NULL);
|
||||
ret = linphone_auth_info_new(username, userid, passwd, ha1, realm, domain);
|
||||
linphone_auth_info_set_tls_cert_path(ret, tls_cert_path);
|
||||
linphone_auth_info_set_tls_key_path(ret, tls_key_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -351,6 +416,13 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info)
|
|||
sai.realm=ai->realm;
|
||||
sai.password=ai->passwd;
|
||||
sai.ha1=ai->ha1;
|
||||
if (ai->tls_cert && ai->tls_key) {
|
||||
sal_certificates_chain_parse(&sai, ai->tls_cert, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse(&sai, ai->tls_key, "");
|
||||
} else if (ai->tls_cert_path && ai->tls_key_path) {
|
||||
sal_certificates_chain_parse_file(&sai, ai->tls_cert_path, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse_file(&sai, ai->tls_key_path, "");
|
||||
}
|
||||
/*proxy case*/
|
||||
for (proxy=(bctbx_list_t*)linphone_core_get_proxy_config_list(lc);proxy!=NULL;proxy=proxy->next) {
|
||||
if (proxy->data == sal_op_get_user_pointer(op)) {
|
||||
|
|
|
|||
|
|
@ -1182,7 +1182,7 @@ void sal_enable_unconditional_answer(Sal *sal,int value) {
|
|||
* @param format either PEM or DER
|
||||
*/
|
||||
void sal_certificates_chain_parse_file(SalAuthInfo* auth_info, const char* path, SalCertificateRawFormat format) {
|
||||
auth_info->certificates = (SalCertificatesChain*) belle_sip_certificates_chain_parse_file(path, (belle_sip_certificate_raw_format_t)format); //
|
||||
auth_info->certificates = (SalCertificatesChain*) belle_sip_certificates_chain_parse_file(path, (belle_sip_certificate_raw_format_t)format);
|
||||
if (auth_info->certificates) belle_sip_object_ref((belle_sip_object_t *) auth_info->certificates);
|
||||
}
|
||||
|
||||
|
|
@ -1196,6 +1196,28 @@ void sal_signing_key_parse_file(SalAuthInfo* auth_info, const char* path, const
|
|||
if (auth_info->key) belle_sip_object_ref((belle_sip_object_t *) auth_info->key);
|
||||
}
|
||||
|
||||
/** Parse a buffer containing either a certificate chain order in PEM format or a single DER cert
|
||||
* @param auth_info structure where to store the result of parsing
|
||||
* @param buffer the buffer to parse
|
||||
* @param format either PEM or DER
|
||||
*/
|
||||
void sal_certificates_chain_parse(SalAuthInfo* auth_info, const char* buffer, SalCertificateRawFormat format) {
|
||||
size_t len = buffer != NULL ? strlen(buffer) : 0;
|
||||
auth_info->certificates = (SalCertificatesChain*) belle_sip_certificates_chain_parse(buffer, len, (belle_sip_certificate_raw_format_t)format);
|
||||
if (auth_info->certificates) belle_sip_object_ref((belle_sip_object_t *) auth_info->certificates);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a buffer containing either a private or public rsa key
|
||||
* @param auth_info structure where to store the result of parsing
|
||||
* @param passwd password (optionnal)
|
||||
*/
|
||||
void sal_signing_key_parse(SalAuthInfo* auth_info, const char* buffer, const char *passwd) {
|
||||
size_t len = buffer != NULL ? strlen(buffer) : 0;
|
||||
auth_info->key = (SalSigningKey *) belle_sip_signing_key_parse(buffer, len, passwd);
|
||||
if (auth_info->key) belle_sip_object_ref((belle_sip_object_t *) auth_info->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a directory to get a certificate with the given subject common name
|
||||
*
|
||||
|
|
|
|||
|
|
@ -970,19 +970,18 @@ static void call_released(SalOp *op){
|
|||
}
|
||||
|
||||
static void auth_failure(SalOp *op, SalAuthInfo* info) {
|
||||
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
|
||||
LinphoneAuthInfo *ai=NULL;
|
||||
|
||||
if( info != NULL ){
|
||||
ai = (LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,info->realm,info->username,info->domain, TRUE);
|
||||
LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
|
||||
LinphoneAuthInfo *ai = NULL;
|
||||
|
||||
if (info != NULL) {
|
||||
ai = (LinphoneAuthInfo*)_linphone_core_find_auth_info(lc, info->realm, info->username, info->domain, TRUE);
|
||||
if (ai){
|
||||
ms_message("%s/%s/%s authentication fails.",info->realm,info->username,info->domain);
|
||||
LinphoneAuthMethod method = info->mode == SalAuthModeHttpDigest ? LinphoneAuthHttpDigest : LinphoneAuthTls;
|
||||
ms_message("%s/%s/%s/%s authentication fails.", info->realm, info->username, info->domain, info->mode == SalAuthModeHttpDigest ? "HttpDigest" : "Tls");
|
||||
/*ask again for password if auth info was already supplied but apparently not working*/
|
||||
linphone_core_notify_auth_info_requested(lc,info->realm,info->username,info->domain);
|
||||
linphone_core_notify_auth_info_requested(lc, info->realm, info->username, info->domain, method);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void register_success(SalOp *op, bool_t registered){
|
||||
|
|
@ -1171,35 +1170,50 @@ static void ping_reply(SalOp *op){
|
|||
}
|
||||
|
||||
static bool_t fill_auth_info_with_client_certificate(LinphoneCore *lc, SalAuthInfo* sai) {
|
||||
const char *chain_file = lp_config_get_string(lc->config,"sip","client_cert_chain", 0);
|
||||
const char *key_file = lp_config_get_string(lc->config,"sip","client_cert_key", 0);;
|
||||
const char *chain_file = linphone_core_get_tls_cert_path(lc);
|
||||
const char *key_file = linphone_core_get_tls_key_path(lc);
|
||||
|
||||
if (key_file && chain_file) {
|
||||
#ifndef _WIN32
|
||||
{
|
||||
// optinal check for files
|
||||
struct stat st;
|
||||
if (stat(key_file,&st)) {
|
||||
ms_warning("No client certificate key found in %s", key_file);
|
||||
return FALSE;
|
||||
}
|
||||
if (stat(chain_file,&st)) {
|
||||
ms_warning("No client certificate chain found in %s", chain_file);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
// optinal check for files
|
||||
struct stat st;
|
||||
if (stat(key_file, &st)) {
|
||||
ms_warning("No client certificate key found in %s", key_file);
|
||||
return FALSE;
|
||||
}
|
||||
if (stat(chain_file, &st)) {
|
||||
ms_warning("No client certificate chain found in %s", chain_file);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
sal_certificates_chain_parse_file(sai, chain_file, SAL_CERTIFICATE_RAW_FORMAT_PEM );
|
||||
sal_signing_key_parse_file(sai, key_file, "");
|
||||
sal_certificates_chain_parse_file(sai, chain_file, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse_file(sai, key_file, "");
|
||||
} else if (lc->tls_cert && lc->tls_key) {
|
||||
sal_certificates_chain_parse(sai, lc->tls_cert, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse(sai, lc->tls_key, "");
|
||||
}
|
||||
return sai->certificates && sai->key;
|
||||
}
|
||||
|
||||
static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) {
|
||||
LinphoneAuthInfo *ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,sai->realm,sai->username,sai->domain, FALSE);
|
||||
if (ai) {
|
||||
sai->userid=ms_strdup(ai->userid?ai->userid:ai->username);
|
||||
sai->password=ai->passwd?ms_strdup(ai->passwd):NULL;
|
||||
sai->ha1=ai->ha1?ms_strdup(ai->ha1):NULL;
|
||||
if (sai->mode == SalAuthModeHttpDigest) {
|
||||
sai->userid=ms_strdup(ai->userid?ai->userid:ai->username);
|
||||
sai->password=ai->passwd?ms_strdup(ai->passwd):NULL;
|
||||
sai->ha1=ai->ha1?ms_strdup(ai->ha1):NULL;
|
||||
} else if (sai->mode == SalAuthModeTls) {
|
||||
if (ai->tls_cert && ai->tls_key) {
|
||||
sal_certificates_chain_parse(sai, ai->tls_cert, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse(sai, ai->tls_key, "");
|
||||
} else if (ai->tls_cert_path && ai->tls_key_path) {
|
||||
sal_certificates_chain_parse_file(sai, ai->tls_cert_path, SAL_CERTIFICATE_RAW_FORMAT_PEM);
|
||||
sal_signing_key_parse_file(sai, ai->tls_key_path, "");
|
||||
} else {
|
||||
fill_auth_info_with_client_certificate(lc, sai);
|
||||
}
|
||||
}
|
||||
|
||||
if (sai->realm && !ai->realm){
|
||||
/*if realm was not known, then set it so that ha1 may eventually be calculated and clear text password dropped*/
|
||||
linphone_auth_info_set_realm(ai, sai->realm);
|
||||
|
|
@ -1211,22 +1225,15 @@ static bool_t fill_auth_info(LinphoneCore *lc, SalAuthInfo* sai) {
|
|||
}
|
||||
}
|
||||
static bool_t auth_requested(Sal* sal, SalAuthInfo* sai) {
|
||||
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
|
||||
if (sai->mode == SalAuthModeHttpDigest) {
|
||||
if (fill_auth_info(lc,sai)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
{
|
||||
linphone_core_notify_auth_info_requested(lc,sai->realm,sai->username,sai->domain);
|
||||
if (fill_auth_info(lc,sai)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
} else if (sai->mode == SalAuthModeTls) {
|
||||
return fill_auth_info_with_client_certificate(lc,sai);
|
||||
LinphoneCore *lc = (LinphoneCore *)sal_get_user_pointer(sal);
|
||||
if (fill_auth_info(lc,sai)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
LinphoneAuthMethod method = sai->mode == SalAuthModeHttpDigest ? LinphoneAuthHttpDigest : LinphoneAuthTls;
|
||||
linphone_core_notify_auth_info_requested(lc, sai->realm, sai->username, sai->domain, method);
|
||||
if (fill_auth_info(lc, sai)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
|
|||
|
||||
@Override
|
||||
public void authInfoRequested(LinphoneCore lc, String realm,
|
||||
String username, String Domain) {
|
||||
String username, String Domain, LinphoneCore.AuthMethod method) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
|
|||
|
||||
public void show(LinphoneCore lc) {}
|
||||
public void byeReceived(LinphoneCore lc, String from) {}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain, LinphoneCore.AuthMethod method) {}
|
||||
public void displayStatus(LinphoneCore lc, String message) {}
|
||||
public void displayMessage(LinphoneCore lc, String message) {}
|
||||
public void displayWarning(LinphoneCore lc, String message) {}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
|
|||
|
||||
public void show(LinphoneCore lc) {}
|
||||
public void byeReceived(LinphoneCore lc, String from) {}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain, LinphoneCore.AuthMethod method) {}
|
||||
public void displayStatus(LinphoneCore lc, String message) {}
|
||||
public void displayMessage(LinphoneCore lc, String message) {}
|
||||
public void displayWarning(LinphoneCore lc, String message) {}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class TutorialRegistration implements LinphoneCoreListener {
|
|||
|
||||
public void show(LinphoneCore lc) {}
|
||||
public void byeReceived(LinphoneCore lc, String from) {}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain, LinphoneCore.AuthMethod method) {}
|
||||
public void displayStatus(LinphoneCore lc, String message) {}
|
||||
public void displayMessage(LinphoneCore lc, String message) {}
|
||||
public void displayWarning(LinphoneCore lc, String message) {}
|
||||
|
|
|
|||
|
|
@ -7929,3 +7929,45 @@ int linphone_core_stop_conference_recording(LinphoneCore *lc) {
|
|||
LinphoneConference *linphone_core_get_conference(LinphoneCore *lc) {
|
||||
return lc->conf_ctx;
|
||||
}
|
||||
|
||||
void linphone_core_set_tls_cert(LinphoneCore *lc, const char *tls_cert) {
|
||||
if (lc->tls_cert) {
|
||||
ms_free(lc->tls_cert);
|
||||
lc->tls_cert = NULL;
|
||||
}
|
||||
if (tls_cert && strlen(tls_cert) > 0) lc->tls_cert = ms_strdup(tls_cert);
|
||||
}
|
||||
|
||||
void linphone_core_set_tls_key(LinphoneCore *lc, const char *tls_key) {
|
||||
if (lc->tls_key) {
|
||||
ms_free(lc->tls_key);
|
||||
lc->tls_key = NULL;
|
||||
}
|
||||
if (tls_key && strlen(tls_key) > 0) lc->tls_key = ms_strdup(tls_key);
|
||||
}
|
||||
|
||||
void linphone_core_set_tls_cert_path(LinphoneCore *lc, const char *tls_cert_path) {
|
||||
lp_config_set_string(lc->config, "sip", "client_cert_key", tls_cert_path);
|
||||
}
|
||||
|
||||
void linphone_core_set_tls_key_path(LinphoneCore *lc, const char *tls_key_path) {
|
||||
lp_config_set_string(lc->config, "sip", "client_cert_chain", tls_key_path);
|
||||
}
|
||||
|
||||
const char *linphone_core_get_tls_cert(const LinphoneCore *lc) {
|
||||
return lc->tls_cert;
|
||||
}
|
||||
|
||||
const char *linphone_core_get_tls_key(const LinphoneCore *lc) {
|
||||
return lc->tls_key;
|
||||
}
|
||||
|
||||
const char *linphone_core_get_tls_cert_path(const LinphoneCore *lc) {
|
||||
const char *tls_cert_path = lp_config_get_string(lc->config, "sip", "client_cert_chain", NULL);
|
||||
return tls_cert_path;
|
||||
}
|
||||
|
||||
const char *linphone_core_get_tls_key_path(const LinphoneCore *lc) {
|
||||
const char *tls_key_path = lp_config_get_string(lc->config, "sip", "client_cert_key", NULL);
|
||||
return tls_key_path;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,6 +226,21 @@ LINPHONE_PUBLIC const char *linphone_reason_to_string(LinphoneReason err);
|
|||
**/
|
||||
typedef struct _LinphoneErrorInfo LinphoneErrorInfo;
|
||||
|
||||
/**
|
||||
* Enum describing the authentication methods
|
||||
* @ingroup network_parameters
|
||||
**/
|
||||
enum _LinphoneAuthMethod {
|
||||
LinphoneAuthHttpDigest, /* Digest authentication requested */
|
||||
LinphoneAuthTls, /* Client certificate requested */
|
||||
};
|
||||
|
||||
/**
|
||||
* Typedef for authentication methods enum.
|
||||
* @ingroup network_parameters
|
||||
**/
|
||||
typedef enum _LinphoneAuthMethod LinphoneAuthMethod;
|
||||
|
||||
LINPHONE_PUBLIC LinphoneReason linphone_error_info_get_reason(const LinphoneErrorInfo *ei);
|
||||
LINPHONE_PUBLIC const char *linphone_error_info_get_phrase(const LinphoneErrorInfo *ei);
|
||||
LINPHONE_PUBLIC const char *linphone_error_info_get_details(const LinphoneErrorInfo *ei);
|
||||
|
|
@ -1154,6 +1169,34 @@ LINPHONE_PUBLIC void linphone_auth_info_set_domain(LinphoneAuthInfo *info, const
|
|||
**/
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_ha1(LinphoneAuthInfo *info, const char *ha1);
|
||||
|
||||
/**
|
||||
* Sets the TLS certificate.
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @param[in] ha1 The TLS certificate.
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_tls_cert(LinphoneAuthInfo *info, const char *tls_cert);
|
||||
|
||||
/**
|
||||
* Sets the TLS key.
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @param[in] ha1 The TLS key.
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_tls_key(LinphoneAuthInfo *info, const char *tls_key);
|
||||
|
||||
/**
|
||||
* Sets the TLS certificate path.
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @param[in] ha1 The TLS certificate path.
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_tls_cert_path(LinphoneAuthInfo *info, const char *tls_cert_path);
|
||||
|
||||
/**
|
||||
* Sets the TLS key path.
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @param[in] ha1 The TLS key path.
|
||||
**/
|
||||
LINPHONE_PUBLIC void linphone_auth_info_set_tls_key_path(LinphoneAuthInfo *info, const char *tls_key_path);
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
*
|
||||
|
|
@ -1202,6 +1245,38 @@ LINPHONE_PUBLIC const char *linphone_auth_info_get_domain(const LinphoneAuthInfo
|
|||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_auth_info_get_ha1(const LinphoneAuthInfo *info);
|
||||
|
||||
/**
|
||||
* Gets the TLS certificate.
|
||||
*
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @return The TLS certificate.
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_auth_info_get_tls_cert(const LinphoneAuthInfo *info);
|
||||
|
||||
/**
|
||||
* Gets the TLS key.
|
||||
*
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @return The TLS key.
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_auth_info_get_tls_key(const LinphoneAuthInfo *info);
|
||||
|
||||
/**
|
||||
* Gets the TLS certificate path.
|
||||
*
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @return The TLS certificate path.
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_auth_info_get_tls_cert_path(const LinphoneAuthInfo *info);
|
||||
|
||||
/**
|
||||
* Gets the TLS key path.
|
||||
*
|
||||
* @param[in] info The #LinphoneAuthInfo object
|
||||
* @return The TLS key path.
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_auth_info_get_tls_key_path(const LinphoneAuthInfo *info);
|
||||
|
||||
/* you don't need those function*/
|
||||
LINPHONE_PUBLIC void linphone_auth_info_destroy(LinphoneAuthInfo *info);
|
||||
LINPHONE_PUBLIC LinphoneAuthInfo * linphone_auth_info_new_from_config_file(LpConfig *config, int pos);
|
||||
|
|
@ -1950,9 +2025,10 @@ typedef void (*LinphoneCoreNewSubscriptionRequestedCb)(LinphoneCore *lc, Linphon
|
|||
* @param lc the LinphoneCore
|
||||
* @param realm the realm (domain) on which authentication is required.
|
||||
* @param username the username that needs to be authenticated.
|
||||
* @param method the type of authentication requested
|
||||
* Application shall reply to this callback using linphone_core_add_auth_info().
|
||||
*/
|
||||
typedef void (*LinphoneCoreAuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
|
||||
typedef void (*LinphoneCoreAuthInfoRequestedCb)(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
|
||||
|
||||
/**
|
||||
* Callback to notify a new call-log entry has been added.
|
||||
|
|
@ -4556,6 +4632,74 @@ typedef struct _LinphoneRingtonePlayer LinphoneRingtonePlayer;
|
|||
|
||||
LINPHONE_PUBLIC LinphoneRingtonePlayer *linphone_core_get_ringtoneplayer(LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Sets a TLS certificate used for TLS authentication
|
||||
* The certificate won't be stored, you have to set it after each LinphoneCore startup
|
||||
* @param lc LinphoneCore object
|
||||
* @param tls_cert the TLS certificate
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_set_tls_cert(LinphoneCore *lc, const char *tls_cert);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Sets a TLS key used for TLS authentication
|
||||
* The key won't be stored, you have to set it after each LinphoneCore startup
|
||||
* @param lc LinphoneCore object
|
||||
* @param tls_key the TLS key
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_set_tls_key(LinphoneCore *lc, const char *tls_key);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Sets a TLS certificate path used for TLS authentication
|
||||
* The path will be stored in the rc file and automatically restored on startup
|
||||
* @param lc LinphoneCore object
|
||||
* @param tls_cert_path path to the TLS certificate
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_set_tls_cert_path(LinphoneCore *lc, const char *tls_cert_path);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Sets a TLS key path used for TLS authentication
|
||||
* The path will be stored in the rc file and automatically restored on startup
|
||||
* @param lc LinphoneCore object
|
||||
* @param tls_key_path path to the TLS key
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_set_tls_key_path(LinphoneCore *lc, const char *tls_key_path);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Gets the TLS certificate
|
||||
* @param lc LinphoneCore object
|
||||
* @return the TLS certificate or NULL if not set yet
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_core_get_tls_cert(const LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Gets the TLS key
|
||||
* @param lc LinphoneCore object
|
||||
* @return the TLS key or NULL if not set yet
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_core_get_tls_key(const LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Gets the path to the TLS certificate file
|
||||
* @param lc LinphoneCore object
|
||||
* @return the TLS certificate path or NULL if not set yet
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_core_get_tls_cert_path(const LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* @ingroup network_parameters
|
||||
* Gets the path to the TLS key file
|
||||
* @param lc LinphoneCore object
|
||||
* @return the TLS key path or NULL if not set yet
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *linphone_core_get_tls_key_path(const LinphoneCore *lc);
|
||||
|
||||
#include "ringtoneplayer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -210,6 +210,9 @@ public:
|
|||
LinphoneJavaBindings(JNIEnv *env) {
|
||||
listenerClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCoreListener"));
|
||||
|
||||
authMethodClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCore$AuthMethod"));
|
||||
authMethodFromIntId = env->GetStaticMethodID(authMethodClass,"fromInt","(I)Lorg/linphone/core/LinphoneCore$AuthMethod;");
|
||||
|
||||
/*displayStatus(LinphoneCore lc,String message);*/
|
||||
displayStatusId = env->GetMethodID(listenerClass,"displayStatus","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;)V");
|
||||
|
||||
|
|
@ -244,7 +247,7 @@ public:
|
|||
/*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/
|
||||
newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V");
|
||||
|
||||
authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/linphone/core/LinphoneCore$AuthMethod;)V");
|
||||
|
||||
/*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/
|
||||
notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V");
|
||||
|
|
@ -350,6 +353,7 @@ public:
|
|||
JNIEnv *env = 0;
|
||||
jvm->AttachCurrentThread(&env,NULL);
|
||||
env->DeleteGlobalRef(listenerClass);
|
||||
env->DeleteGlobalRef(authMethodClass);
|
||||
env->DeleteGlobalRef(globalStateClass);
|
||||
env->DeleteGlobalRef(configuringStateClass);
|
||||
env->DeleteGlobalRef(registrationStateClass);
|
||||
|
|
@ -389,6 +393,9 @@ public:
|
|||
jmethodID authInfoRequestedId;
|
||||
jmethodID publishStateId;
|
||||
jmethodID notifyRecvId;
|
||||
|
||||
jclass authMethodClass;
|
||||
jmethodID authMethodFromIntId;
|
||||
|
||||
jclass configuringStateClass;
|
||||
jmethodID configuringStateId;
|
||||
|
|
@ -857,7 +864,7 @@ public:
|
|||
env->DeleteLocalRef(msg);
|
||||
}
|
||||
}
|
||||
static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
|
||||
static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
if (result != 0) {
|
||||
|
|
@ -876,7 +883,9 @@ public:
|
|||
lcData->core,
|
||||
r,
|
||||
u,
|
||||
d);
|
||||
d,
|
||||
env->CallStaticObjectMethod(ljb->authMethodClass,ljb->authMethodFromIntId,(jint)method)
|
||||
);
|
||||
handle_possible_java_exception(env, lcData->listener);
|
||||
if (r) {
|
||||
env->DeleteLocalRef(r);
|
||||
|
|
|
|||
|
|
@ -662,6 +662,10 @@ struct _LinphoneAuthInfo
|
|||
char *passwd;
|
||||
char *ha1;
|
||||
char *domain;
|
||||
char *tls_cert;
|
||||
char *tls_key;
|
||||
char *tls_cert_path;
|
||||
char *tls_key_path;
|
||||
};
|
||||
|
||||
typedef enum _LinphoneIsComposingState {
|
||||
|
|
@ -1045,6 +1049,10 @@ struct _LinphoneCore
|
|||
|
||||
/*for tests only*/
|
||||
bool_t zrtp_not_available_simulation;
|
||||
|
||||
/* string for TLS auth instead of path to files */
|
||||
char *tls_cert;
|
||||
char *tls_key;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -1492,7 +1500,7 @@ void linphone_core_notify_display_url(LinphoneCore *lc, const char *message, con
|
|||
void linphone_core_notify_notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf);
|
||||
void linphone_core_notify_notify_presence_received_for_uri_or_tel(LinphoneCore *lc, LinphoneFriend *lf, const char *uri_or_tel, const LinphonePresenceModel *presence_model);
|
||||
void linphone_core_notify_new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
|
||||
void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
|
||||
void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
|
||||
void linphone_core_notify_call_log_updated(LinphoneCore *lc, LinphoneCallLog *newcl);
|
||||
void linphone_core_notify_text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message);
|
||||
void linphone_core_notify_message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message);
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ void linphone_core_notify_new_subscription_requested(LinphoneCore *lc, LinphoneF
|
|||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
|
||||
NOTIFY_IF_EXIST(auth_info_requested, lc, realm, username, domain);
|
||||
void linphone_core_notify_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
|
||||
NOTIFY_IF_EXIST(auth_info_requested, lc, realm, username, domain, method);
|
||||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ static void linphone_gtk_global_state_changed(LinphoneCore *lc, LinphoneGlobalSt
|
|||
static void linphone_gtk_registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState rs, const char *msg);
|
||||
static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid);
|
||||
static void linphone_gtk_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
|
||||
static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain);
|
||||
static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method);
|
||||
static void linphone_gtk_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message);
|
||||
static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl);
|
||||
static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg);
|
||||
|
|
@ -1135,7 +1135,7 @@ void linphone_gtk_password_ok(GtkWidget *w){
|
|||
gtk_widget_destroy(window);
|
||||
}
|
||||
|
||||
static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
|
||||
static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method){
|
||||
GtkWidget *w=linphone_gtk_create_window("password", the_ui);
|
||||
GtkWidget *label=linphone_gtk_get_widget(w,"message");
|
||||
LinphoneAuthInfo *info;
|
||||
|
|
|
|||
|
|
@ -580,6 +580,20 @@ void sal_certificates_chain_parse_file(SalAuthInfo* auth_info, const char* path,
|
|||
*/
|
||||
void sal_signing_key_parse_file(SalAuthInfo* auth_info, const char* path, const char *passwd);
|
||||
|
||||
/** Parse a buffer containing either a certificate chain order in PEM format or a single DER cert
|
||||
* @param auth_info structure where to store the result of parsing
|
||||
* @param buffer the buffer to parse
|
||||
* @param format either PEM or DER
|
||||
*/
|
||||
void sal_certificates_chain_parse(SalAuthInfo* auth_info, const char* buffer, SalCertificateRawFormat format);
|
||||
|
||||
/**
|
||||
* Parse a buffer containing either a private or public rsa key
|
||||
* @param auth_info structure where to store the result of parsing
|
||||
* @param passwd password (optionnal)
|
||||
*/
|
||||
void sal_signing_key_parse(SalAuthInfo* auth_info, const char* buffer, const char *passwd);
|
||||
|
||||
/**
|
||||
* Parse a directory for files containing certificate with the given subject CNAME
|
||||
* @param[out] certificate_pem the address of a string to store the certificate in PEM format. To be freed by caller
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public interface LinphoneCore {
|
|||
public String toString() {
|
||||
return mStringValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* linphone remote provisioning states
|
||||
*/
|
||||
|
|
@ -597,6 +597,40 @@ public interface LinphoneCore {
|
|||
return mStringValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* linphone authentication methods
|
||||
*/
|
||||
static public class AuthMethod {
|
||||
static private Vector<AuthMethod> values = new Vector<AuthMethod>();
|
||||
/**
|
||||
* HTTP Digest
|
||||
*/
|
||||
static public AuthMethod AuthMethodHttpDigest = new AuthMethod(0, "AuthMethodHttpDigest");
|
||||
/**
|
||||
* TLS
|
||||
*/
|
||||
static public AuthMethod AuthMethodTls = new AuthMethod(1, "AuthMethodTls");
|
||||
|
||||
private final int mValue;
|
||||
private final String mStringValue;
|
||||
|
||||
private AuthMethod(int value,String stringValue) {
|
||||
mValue = value;
|
||||
values.addElement(this);
|
||||
mStringValue=stringValue;
|
||||
}
|
||||
public static AuthMethod fromInt(int value) {
|
||||
|
||||
for (int i=0; i<values.size();i++) {
|
||||
AuthMethod state = (AuthMethod) values.elementAt(i);
|
||||
if (state.mValue == value) return state;
|
||||
}
|
||||
throw new RuntimeException("auth method not found ["+value+"]");
|
||||
}
|
||||
public String toString() {
|
||||
return mStringValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the context of creation of the LinphoneCore.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public interface LinphoneCoreListener {
|
|||
|
||||
/**< Ask the application some authentication information
|
||||
* @return */
|
||||
void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain);
|
||||
void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain, LinphoneCore.AuthMethod method);
|
||||
|
||||
/**
|
||||
* Call stats notification
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class LinphoneCoreListenerBase implements LinphoneCoreListener {
|
|||
|
||||
@Override
|
||||
public void authInfoRequested(LinphoneCore lc, String realm,
|
||||
String username, String Domain) {
|
||||
String username, String Domain, LinphoneCore.AuthMethod method) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ static void account_created_on_server_cb(LinphoneCore *lc, LinphoneProxyConfig *
|
|||
// TEMPORARY CODE: remove function below when flexisip is updated, this is not needed anymore!
|
||||
// The new flexisip now answer "200 Test account created" when creating a test account, and do not
|
||||
// challenge authentication anymore! so this code is not used for newer version
|
||||
static void account_created_auth_requested_cb(LinphoneCore *lc, const char *username, const char *realm, const char *domain){
|
||||
static void account_created_auth_requested_cb(LinphoneCore *lc, const char *username, const char *realm, const char *domain, LinphoneAuthMethod method){
|
||||
Account *account=(Account*)linphone_core_get_user_data(lc);
|
||||
account->created=1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ static void text_message_within_call_dialog(void) {
|
|||
}
|
||||
|
||||
static LinphoneAuthInfo* text_message_with_credential_from_auth_cb_auth_info;
|
||||
static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
|
||||
static void text_message_with_credential_from_auth_cb_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
|
||||
ms_message("text_message_with_credential_from_auth_callback:Auth info requested for user id [%s] at realm [%s]\n"
|
||||
,username
|
||||
,realm);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
|
||||
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
|
||||
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
|
||||
LinphoneAuthInfo *info;
|
||||
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,realm,domain); /*create authentication structure from identity*/
|
||||
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ LinphoneAddress * create_linphone_address(const char * domain) {
|
|||
return addr;
|
||||
}
|
||||
|
||||
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
|
||||
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method) {
|
||||
stats* counters;
|
||||
ms_message("Auth info requested for user id [%s] at realm [%s]\n"
|
||||
,username
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ static void on_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageSt
|
|||
}
|
||||
}
|
||||
|
||||
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain){
|
||||
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain, LinphoneAuthMethod method){
|
||||
running = FALSE;
|
||||
if (passwd){
|
||||
fprintf(stderr, "Server rejected the supplied username or password\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue