Merge pull request #3 from kovetskiy/master

refactoring
fix #2 and #3 bug
fix problem with x509 certificate (tls, comodo)