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