diff options
author | Simon Josefsson <simon@josefsson.org> | 2007-05-27 17:21:50 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2007-05-27 17:21:50 +0200 |
commit | eeccf7ae2bd5840a0ba5580fd0e74d50340033c0 (patch) | |
tree | dd0b2495c7e7ccbcb5cf935d787ef0fc6321098e /tests/parse_ca.c | |
parent | c5637a5d27fa9c92db33f5b20b767da602ab6b7f (diff) | |
download | gnutls-eeccf7ae2bd5840a0ba5580fd0e74d50340033c0.tar.gz |
Add self-test.
Diffstat (limited to 'tests/parse_ca.c')
-rw-r--r-- | tests/parse_ca.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/parse_ca.c b/tests/parse_ca.c new file mode 100644 index 0000000000..bd5e78bb72 --- /dev/null +++ b/tests/parse_ca.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2007 Free Software Foundation + * + * Author: Simon Josefsson + * + * This file is part of GNUTLS. + * + * GNUTLS is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GNUTLS is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNUTLS; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> + +#include "utils.h" + +const static char castr[] = + "-----BEGIN CERTIFICATE-----\r\n" + "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\r\n" + "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTExWhcNMDgwNDE3MTMyOTExWjAZMRcw\r\n" + "FQYDVQQDEw5HbnVUTFMgdGVzdCBDQTCBnDALBgkqhkiG9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BTpPBz7rZJu5gak\r\n" + "Viyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAiaIRqGfp1jPpNeVhABK60SU0KIAy\r\n" + "njuu7kHq5peUgYn8Jd9zNzExBOEp1VOipGsf6G66oQAhDFp2o8zkz7ZH71zR4HEW\r\n" + "KoX6n5Emn6DvcEH/9pAhnGxNHJAoS7czTKv/JDZJhkqHxyrE1fuLsg5Qv25DTw7+\r\n" + "PfqUpIhz5Bbm7J4=\r\n" + "-----END CERTIFICATE-----\r\n"; + +void +doit (void) +{ + int rc; + gnutls_certificate_credentials_t cred; + gnutls_datum_t ca = { castr, sizeof (castr) }; + + gnutls_global_init(); + + rc = gnutls_certificate_allocate_credentials (&cred); + if (rc) + fail ("allocate cred failed: %d\n", rc); + + rc = gnutls_certificate_set_x509_trust_mem (cred, &ca, GNUTLS_X509_FMT_PEM); + if (rc != 2) + fail ("import ca failed: %d\n", rc); + + gnutls_certificate_free_credentials (cred); + + gnutls_global_deinit(); + + success ("import ok\n"); +} |