Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Register pjsip account using Tls setting in pjsua

I am using Pjusa for Voip, I have done communication through UDP and TCP but could not communitcate through TLS setting`

TlsConfig tlsConfig = new TlsConfig();
File cacheDir = new File(ctx.getCacheDir(), "ca");
InputStream input = ctx.getResources().openRawResource(R.raw.ca);
tlsConfig.setCaListFile(cacheDir.getPath());
input = ctx.getResources().openRawResource(R.raw.secure);
cacheDir = new File(ctx.getCacheDir(), "secure");
tlsConfig.setCertFile(cacheDir.getPath());
tlsConfig.setMethod(pjsip_ssl_method.PJSIP_SSLV23_METHOD);` 

I have attached CaListFile and setCertFile files like that method and that setting working but When I establish a call then I found error like that

tlsc0x9e7db014 TLS connect() error: Connection refused [code=120111] tsx0x9d945864 Failed to send Request msg INVITE/cseq=25416 (tdta0x9d991000)! err=120111 (Connection refused)

In IOS I found some more setting for TLS , but could not implement in PJSUA any one can help me out how to use that piece of code in android in PJSUA library

 pj_sockaddr_in remote;
pjsip_transport *transport;
remote.sin_family = pj_AF_INET();
remote.sin_zero_len   =   0;
remote.sin_addr.s_addr = pj_inet_addr(@"xxx.xx.xx.xx").s_addr;
remote.sin_addr.s_addr = INADDR_ANY;
bzero(&(remote.sin_zero),sizeof(remote.sin_zero));

app_config->cfg.use_srtp = PJMEDIA_SRTP_MANDATORY;
app_config->cfg.srtp_secure_signaling = 1;

thanks in advance

like image 566
Munir Avatar asked Oct 31 '22 06:10

Munir


1 Answers

TlsConfig tlsConfig = new TlsConfig();

tlsConfig.setCertFile(certFile);

sipTpConfig.setTlsConfig(tlsConfig);
tlsConfig.setCaListFile(caListFile);

I did R&D from web searching and reading document of SIP and PJSIP, then I find the sluotion for accountConfig for PJMEDIA_SRTP_MANDATORY and setSrtpSecureSignaling(1) by that way provided below

accCfg.getMediaConfig().setSrtpUse(pjmedia_srtp_use.PJMEDIA_SRTP_MANDATORY);
accCfg.getMediaConfig().setSrtpSecureSignaling(1);

Hence TLS working with CAListFile and CertificateFile

like image 128
Khawaja Hammad Avatar answered Nov 09 '22 14:11

Khawaja Hammad