tls: the pointer of cfg structure

- synchronize when updating the list of tls configs and their reference
  count
- with parts from patch by Ding Ma, FS#380, contributed under BSD
  license
- backport of 208934d47ac1585d42029234267bcceab40ae218