Martin Lambers | 5 Feb 16:26 2005
Picon

Sending a client certificate

I'm trying to send a client certificate when starting a TLS handshake
with a server. 
Currently, I use the following steps (plus error checking, of course):

gnutls_init(&session, GNUTLS_CLIENT);
gnutls_set_default_priority(session);
gnutls_certificate_allocate_credentials(&cred);
gnutls_certificate_set_x509_key_file(cred, 
    "cert_file.pem", "key_file.pem", GNUTLS_X509_FMT_PEM);
gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred);
gnutls_transport_set_ptr(session, fd);
gnutls_handshake(session);

But this does not work; no client certificate is send. Are there more
steps necessary? Am I missing something?

I used both GnuTLS 1.0.17 and 1.2.0.

Martin
Nikos Mavrogiannopoulos | 5 Feb 19:02 2005

Re: Sending a client certificate

On Saturday 05 February 2005 16:26, Martin Lambers wrote:

> I'm trying to send a client certificate when starting a TLS handshake
> with a server.
Does the server request a certificate? If it doesn't then no matter if
you specify one, it will not be used. Otherwise please attach the
output of ssldump, or the debug output of level 3.

> Martin

--

-- 
Nikos Mavrogiannopoulos
Martin Lambers | 5 Feb 19:47 2005
Picon

Re: Sending a client certificate

On Sat, 05. Feb 2005, 19:02:34 +0100, Nikos Mavrogiannopoulos wrote:
> Does the server request a certificate? If it doesn't then no matter if
> you specify one, it will not be used. Otherwise please attach the
> output of ssldump, or the debug output of level 3.

This is the level 3 debug output:

GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_AES_256_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_AES_256_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_AES_128_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_AES_128_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_3DES_EDE_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_3DES_EDE_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_ARCFOUR_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: RSA_ARCFOUR_MD5
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_AES_256_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_AES_256_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_AES_128_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_AES_128_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_3DES_EDE_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_3DES_EDE_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_DSS_ARCFOUR_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_RSA_AES_256_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_RSA_AES_256_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_RSA_AES_128_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_RSA_AES_128_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_RSA_3DES_EDE_CBC_SHA
GNUTLS DEBUG 3: HSK[8076ad0]: Keeping ciphersuite: DHE_RSA_3DES_EDE_CBC_RMD
GNUTLS DEBUG 3: HSK[8076ad0]: CLIENT HELLO was send [85 bytes]
GNUTLS DEBUG 3: HSK[8076ad0]: SERVER HELLO was received [74 bytes]
(Continue reading)

Nikos Mavrogiannopoulos | 5 Feb 21:27 2005

Re: Sending a client certificate

On Saturday 05 February 2005 19:47, Martin Lambers wrote:
> On Sat, 05. Feb 2005, 19:02:34 +0100, Nikos Mavrogiannopoulos wrote:
> > Does the server request a certificate? If it doesn't then no matter if
> > you specify one, it will not be used. Otherwise please attach the
> > output of ssldump, or the debug output of level 3.
>
> This is the level 3 debug output:

> GNUTLS DEBUG 3: HSK[8076ad0]: CERTIFICATE was received [1454 bytes]
> GNUTLS DEBUG 3: HSK[8076ad0]: CERTIFICATE REQUEST was received [137 bytes]
> GNUTLS DEBUG 2: ASSERT: auth_cert.c:198
> GNUTLS DEBUG 3: HSK[8076ad0]: SERVER HELLO DONE was received [4 bytes]
> GNUTLS DEBUG 3: HSK[8076ad0]: CERTIFICATE was send [7 bytes]
So it seems you got a certificate request and the certificate gnutls select is 
empty. This might be because your certificate does not
match the CAs advertized by the server. You can check the CAs advertized
by the server by using gnutls-cli. If you want to override the server's
request, and send anyway a certificate you have to use the retrieve[0]
function as used in gnutls-cli (cli.c).

[0]. gnutls_certificate_client_set_retrieve_function()

--

-- 
Nikos Mavrogiannopoulos
Martin Lambers | 6 Feb 14:18 2005
Picon

Re: Sending a client certificate

On Sat, 05. Feb 2005, 21:27:06 +0100, Nikos Mavrogiannopoulos wrote:
> So it seems you got a certificate request and the certificate gnutls
> select is empty. This might be because your certificate does not match
> the CAs advertized by the server.

This was the problem. I did not know that GnuTLS sends the cert only if
it matches the CAs advertized by the server.

Thanks for your help!

Martin
Eric Leblond | 6 Feb 14:21 2005
Picon

Re: Sending a client certificate

Hi,

I've got a related question about handling of passphrase protected
certificate ?

How can this be done ?

BR

On Sat, 2005-02-05 at 16:26 +0100, Martin Lambers wrote:
> I'm trying to send a client certificate when starting a TLS handshake
> with a server. 
> Currently, I use the following steps (plus error checking, of course):
> 
> gnutls_init(&session, GNUTLS_CLIENT);
> gnutls_set_default_priority(session);
> gnutls_certificate_allocate_credentials(&cred);
> gnutls_certificate_set_x509_key_file(cred, 
>     "cert_file.pem", "key_file.pem", GNUTLS_X509_FMT_PEM);
> gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cred);
> gnutls_transport_set_ptr(session, fd);
> gnutls_handshake(session);
> 
> But this does not work; no client certificate is send. Are there more
> steps necessary? Am I missing something?
> 
> I used both GnuTLS 1.0.17 and 1.2.0.
> 
> Martin
> 
(Continue reading)

Nikos Mavrogiannopoulos | 6 Feb 14:59 2005

Re: Sending a client certificate

On Sunday 06 February 2005 14:21, Eric Leblond wrote:
> Hi,
>
> I've got a related question about handling of passphrase protected
> certificate ?
> How can this be done ?
You probably mean an encrypted private key. This can be done, if the
key is stored in PKCS #8/12 format, so you only have to use the relevant
pkcs8/12 functions to import it. Other formats like the pem encryption
(i think this is rfc1421) are not supported.

> BR

--

-- 
Nikos Mavrogiannopoulos
Simon Josefsson | 6 Feb 15:23 2005

Re: Sending a client certificate

Eric Leblond <regit <at> inl.fr> writes:

> Hi,
>
> I've got a related question about handling of passphrase protected
> certificate ?
>
> How can this be done ?

You can use `gnutls_pkcs12_bag_decrypt' to decrypt a PKCS#12
structure.

There is more than one way to store protected keys and certificates,
so if you aren't using PKCS#12, you need to tell us which format you
want to use.

Regards,
Simon

Gmane