TLS چیست؟

در واقع TLS کامل کننده پروتکل امن SSL است و برای انتقال امن داده‌ها ما بین دو دستگاه در شبکه استفاده می‌شود. محل قرار گیری TLS براساس استاندار OSI لایه Application است. در پروتکل TLS احراز هویت با استفاده از  Certificate صورت می‌گیرد که به دو روش یک طرفه و دو طرفه انجام می‌شود. در حالت یک طرفه سرور تنها سرور احراز هویت می‌شود و client از اصالت سرور اطمینان حاصل می‌کند. در حالت دوم سرور certificate دستگاه client را بررسی و از اصالت آن اطمینان حاصل می‌کند. سپس از جابجایی packet به صورت encrypted آغاز می‌شود.

 

کاربردهای TLS در دنیای VOIP:

با قرار دادن Certificate TLS بر روی سرورهای تلفنی و گوشی‌ها ارتباط بین سرورها و ارتباط گوشی‌ها با سرورها ایمن‌سازی می‌شود. از قابلیت‌های مهم TLS ایمن‌سازی ارتباط بدون نیاز به ورود اطلاعات کاربری (نام کاربری و رمز عبور) است.

 

 انتقال بر روی TLS در Asterisk:

برای استفاده از TLS دستگاه خدمات گیرنده (client)، معتبر بودن certifiacate را چک خواهد کرد که در این صورت می‌بایست توسط یک CA اصلی امضا شود و یا باید CA Certificate بر روی دستگاه client قرار گیرد.

 

تنظیمات مرتبط با TLS در فایل sip.conf:

  • tlsenable=yes - Enable TLS server, default is no
  • tlsbindaddr=<ip address> - Specify IP address to bind TLS server to, default is 0.0.0.0
  • tlscertfile=</path/to/certificate> - The server's certificate file. Should include the key and certificate. This is mandatory if you're going to run a TLS server.
  • tlscafile=</path/to/certificate> - If the server you're connecting to uses a self signed certificate you should have their certificate installed here so the code can verify the authenticity of their certificate.
  • tlscapath=</path/to/ca/dir> - A directory full of CA certificates. The files must be named with the CA subject name hash value. (see man SSL_CTX_load_verify_locations for more info)
  • tlsdontverifyserver=yes - If set to yes, don't verify the servers certificate when acting as a client. If you don't have the server's CA certificate you can set this and it will connect without requiring tlscafile to be set. Default is no.
  • tlscipher=<SSL cipher string> - A string specifying which SSL ciphers to use or not use. A list of valid SSL cipher strings can be found at http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS

برای ایجاد کلید Asterisk می‌توانید از commend زیر استفاده کنید:

openssl genrsa -out key.pem 1024

در این قسمت ایجاد SSL Certificate را خواهیم داشت:

openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out asterisk.pem

در ادامه، تنظیمات دو سرور Asterisk برای اتصال به یکدیگر با پروتکل TLS توضیح داده شده است:

سرور اول:

[general]
tlsenable=yes
tlscertfile=/etc/asterisk/asterisk.pem
tlscafile=/etc/ssl/ca.pem  ; This is the CA file used to generate both certificates
register => tls://100:test@192.168.0.100:5061
 
[101]
type=friend
context=internal
host=192.168.0.100 ; The host should be either IP or hostname and should
; match the 'common name' field in the servers certificate
secret=test
dtmfmode=rfc2833
disallow=all
allow=ulaw
transport=tls
port=5061

سرور دوم:

[general]
tlsenable=yes
tlscertfile=/etc/asterisk/asterisk.pem
 
[100]
type=friend
context=internal
host=dynamic
secret=test
dtmfmode=rfc2833
disallow=all
allow=ulaw
;You can specify transport= and port=5061 for TLS, but its not necessary in
;the server configuration, any type of SIP transport will work
;transport=tls
;port=5061

منبع: VOIPIRAN