Client authentication with certificate

I would like to be able to authenticate with a client certificate. If a certificate will be provided, a login should be performed automatically and no login prompt should be shown. If there is no certificate, a basic authentication login should be performed.