use x509 public key and private key instead of defining our own in tls.
misc export and convenience functions in extra.
update debug for tls 1.2