diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-04-28 14:26:19 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-04-28 17:02:03 +0200 |
commit | e3678c63ab566b2c6bb2d93087b488076168f90c (patch) | |
tree | cb865743b7b9872ca2b838d8d7a6adf72e191cd1 /tests/custom-urls.c | |
parent | 7d637c081d679c6dfc16e24f3c2eb05029d9caad (diff) | |
download | gnutls-e3678c63ab566b2c6bb2d93087b488076168f90c.tar.gz |
tests: simplified custom-urls check
Diffstat (limited to 'tests/custom-urls.c')
-rw-r--r-- | tests/custom-urls.c | 57 |
1 files changed, 1 insertions, 56 deletions
diff --git a/tests/custom-urls.c b/tests/custom-urls.c index b5938db41c..41e4bc0234 100644 --- a/tests/custom-urls.c +++ b/tests/custom-urls.c @@ -48,6 +48,7 @@ int main() #include <gnutls/urls.h> #include <signal.h> +#include "cert-common.h" #include "utils.h" static void terminate(void); @@ -60,47 +61,6 @@ static void server_log_func(int level, const char *str) fprintf(stderr, "server|<%d>| %s", level, str); } -static unsigned char server_cert_pem[] = - "-----BEGIN CERTIFICATE-----\n" - "MIICVjCCAcGgAwIBAgIERiYdMTALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n" - "VExTIHRlc3QgQ0EwHhcNMDcwNDE4MTMyOTIxWhcNMDgwNDE3MTMyOTIxWjA3MRsw\n" - "GQYDVQQKExJHbnVUTFMgdGVzdCBzZXJ2ZXIxGDAWBgNVBAMTD3Rlc3QuZ251dGxz\n" - "Lm9yZzCBnDALBgkqhkiG9w0BAQEDgYwAMIGIAoGA17pcr6MM8C6pJ1aqU46o63+B\n" - "dUxrmL5K6rce+EvDasTaDQC46kwTHzYWk95y78akXrJutsoKiFV1kJbtple8DDt2\n" - "DZcevensf9Op7PuFZKBroEjOd35znDET/z3IrqVgbtm2jFqab7a+n2q9p/CgMyf1\n" - "tx2S5Zacc1LWn9bIjrECAwEAAaOBkzCBkDAMBgNVHRMBAf8EAjAAMBoGA1UdEQQT\n" - "MBGCD3Rlc3QuZ251dGxzLm9yZzATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHQ8B\n" - "Af8EBQMDB6AAMB0GA1UdDgQWBBTrx0Vu5fglyoyNgw106YbU3VW0dTAfBgNVHSME\n" - "GDAWgBTpPBz7rZJu5gakViyi4cBTJ8jylTALBgkqhkiG9w0BAQUDgYEAaFEPTt+7\n" - "bzvBuOf7+QmeQcn29kT6Bsyh1RHJXf8KTk5QRfwp6ogbp94JQWcNQ/S7YDFHglD1\n" - "AwUNBRXwd3riUsMnsxgeSDxYBfJYbDLeohNBsqaPDJb7XailWbMQKfAbFQ8cnOxg\n" - "rOKLUQRWJ0K3HyXRMhbqjdLIaQiCvQLuizo=\n" "-----END CERTIFICATE-----\n"; - -const gnutls_datum_t server_cert = { server_cert_pem, - sizeof(server_cert_pem) -}; - -static unsigned char server_key_pem[] = - "-----BEGIN RSA PRIVATE KEY-----\n" - "MIICXAIBAAKBgQDXulyvowzwLqknVqpTjqjrf4F1TGuYvkrqtx74S8NqxNoNALjq\n" - "TBMfNhaT3nLvxqResm62ygqIVXWQlu2mV7wMO3YNlx696ex/06ns+4VkoGugSM53\n" - "fnOcMRP/PciupWBu2baMWppvtr6far2n8KAzJ/W3HZLllpxzUtaf1siOsQIDAQAB\n" - "AoGAYAFyKkAYC/PYF8e7+X+tsVCHXppp8AoP8TEZuUqOZz/AArVlle/ROrypg5kl\n" - "8YunrvUdzH9R/KZ7saNZlAPLjZyFG9beL/am6Ai7q7Ma5HMqjGU8kTEGwD7K+lbG\n" - "iomokKMOl+kkbY/2sI5Czmbm+/PqLXOjtVc5RAsdbgvtmvkCQQDdV5QuU8jap8Hs\n" - "Eodv/tLJ2z4+SKCV2k/7FXSKWe0vlrq0cl2qZfoTUYRnKRBcWxc9o92DxK44wgPi\n" - "oMQS+O7fAkEA+YG+K9e60sj1K4NYbMPAbYILbZxORDecvP8lcphvwkOVUqbmxOGh\n" - "XRmTZUuhBrJhJKKf6u7gf3KWlPl6ShKEbwJASC118cF6nurTjuLf7YKARDjNTEws\n" - "qZEeQbdWYINAmCMj0RH2P0mvybrsXSOD5UoDAyO7aWuqkHGcCLv6FGG+qwJAOVqq\n" - "tXdUucl6GjOKKw5geIvRRrQMhb/m5scb+5iw8A4LEEHPgGiBaF5NtJZLALgWfo5n\n" - "hmC8+G8F0F78znQtPwJBANexu+Tg5KfOnzSILJMo3oXiXhf5PqXIDmbN0BKyCKAQ\n" - "LfkcEcUbVfmDaHpvzwY9VEaoMOKVLitETXdNSxVpvWM=\n" - "-----END RSA PRIVATE KEY-----\n"; - -const gnutls_datum_t server_key = { server_key_pem, - sizeof(server_key_pem) -}; - static int url_import_key(gnutls_privkey_t pkey, const char *url, unsigned flags) { if (strcmp(url, "myurl:key") != 0) { @@ -120,18 +80,12 @@ static int url_import_crt(gnutls_x509_crt_t crt, const char *url, unsigned flags return gnutls_x509_crt_import(crt, &server_cert, GNUTLS_X509_FMT_PEM); } -/* A very basic TLS client, with anonymous authentication. - */ - static void client(int fd) { int ret; - gnutls_anon_client_credentials_t anoncred; gnutls_certificate_credentials_t x509_cred; gnutls_session_t session; - /* Need to enable anonymous KX specifically. */ - gnutls_anon_allocate_client_credentials(&anoncred); gnutls_certificate_allocate_credentials(&x509_cred); /* Initialize TLS session @@ -141,9 +95,6 @@ static void client(int fd) /* Use default priorities */ gnutls_priority_set_direct(session, "NORMAL", NULL); - /* put the anonymous credentials to the current session - */ - gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); gnutls_transport_set_int(session, fd); @@ -175,7 +126,6 @@ static void client(int fd) gnutls_deinit(session); - gnutls_anon_free_client_credentials(anoncred); gnutls_certificate_free_credentials(x509_cred); gnutls_global_deinit(); @@ -194,7 +144,6 @@ static void server(int fd) { int ret; gnutls_session_t session; - gnutls_anon_server_credentials_t anoncred; gnutls_certificate_credentials_t x509_cred; /* this must be called once in the program @@ -216,8 +165,6 @@ static void server(int fd) terminate(); } - gnutls_anon_allocate_server_credentials(&anoncred); - gnutls_init(&session, GNUTLS_SERVER); /* avoid calling all the priority functions, since the defaults @@ -225,7 +172,6 @@ static void server(int fd) */ gnutls_priority_set_direct(session, "NORMAL", NULL); - gnutls_credentials_set(session, GNUTLS_CRD_ANON, anoncred); gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, x509_cred); gnutls_transport_set_int(session, fd); @@ -256,7 +202,6 @@ static void server(int fd) close(fd); gnutls_deinit(session); - gnutls_anon_free_server_credentials(anoncred); gnutls_certificate_free_credentials(x509_cred); gnutls_global_deinit(); |