added x509 support
rolled version