~ubuntu-branches/ubuntu/quantal/gnutls26/quantal-security

« back to all changes in this revision

Viewing changes to doc/examples/ex-cert-select.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-05-20 13:07:18 UTC
  • mfrom: (12.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20110520130718-db41dybbanzfvlji
Tags: 2.10.5-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Fix build failure with --no-add-needed.
  - Build for multiarch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
  type = gnutls_certificate_type_get (session);
260
260
  if (type == GNUTLS_CRT_X509)
261
261
    {
 
262
      /* check if the certificate we are sending is signed
 
263
       * with an algorithm that the server accepts */
 
264
      gnutls_sign_algorithm_t cert_algo, req_algo;
 
265
      int i, match = 0;
 
266
 
 
267
      ret = gnutls_x509_crt_get_signature_algorithm (crt);
 
268
      if (ret < 0)
 
269
        {
 
270
          /* error reading signature algorithm 
 
271
           */
 
272
          return -1;
 
273
        }
 
274
      cert_algo = ret;
 
275
 
 
276
      i = 0;
 
277
      do
 
278
        {
 
279
          ret = gnutls_sign_algorithm_get_requested (session, i, &req_algo);
 
280
          if (ret >= 0 && cert_algo == req_algo)
 
281
            {
 
282
              match = 1;
 
283
              break;
 
284
            }
 
285
 
 
286
          /* server has not requested anything specific */
 
287
          if (i == 0 && ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
 
288
            {
 
289
              match = 1;
 
290
              break;
 
291
            }
 
292
          i++;
 
293
        }
 
294
      while (ret >= 0);
 
295
 
 
296
      if (match == 0)
 
297
        {
 
298
          printf
 
299
            ("- Could not find a suitable certificate to send to server\n");
 
300
          return -1;
 
301
        }
 
302
 
262
303
      st->type = type;
263
304
      st->ncerts = 1;
264
305