annotate tests/testcnx.c @ 1186:56c36d1007b4

Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
author Sebastien Decugis <sdecugis@freediameter.net>
date Fri, 07 Jun 2013 18:48:34 +0800
parents 22de21feec64
children eff5bb332b5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 729
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
1127
1af09cc156d6 Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
5 * Copyright (c) 2013, WIDE Project and NICT *
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 #include "tests.h"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 #ifndef TEST_PORT
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39 #define TEST_PORT 3868
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 #endif /* TEST_PORT */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
41
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
42 #ifndef NB_STREAMS
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
43 #define NB_STREAMS 10
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
44 #endif /* NB_STREAMS */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
45
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46 #ifndef GNUTLS_DEFAULT_PRIORITY
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47 # define GNUTLS_DEFAULT_PRIORITY "NORMAL"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
48 #endif /* GNUTLS_DEFAULT_PRIORITY */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 #ifndef GNUTLS_DEFAULT_DHBITS
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 # define GNUTLS_DEFAULT_DHBITS 1024
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 #endif /* GNUTLS_DEFAULT_DHBITS */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 /* The cryptographic data */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 static char ca_data[] = "-----BEGIN CERTIFICATE-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 "MIIEqjCCA5KgAwIBAgIJANKgDwdlDYQDMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 "VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNV\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 "BAoMBFdJREUxDzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 "YWRkaWN0Lm9yZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDAe\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 "Fw0wOTEwMDUwODUxNDRaFw0xOTEwMDMwODUxNDRaMIGUMQswCQYDVQQGEwJKUDEO\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 "MAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUx\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63 "DzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293YWRkaWN0Lm9y\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64 "ZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDCCASIwDQYJKoZI\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65 "hvcNAQEBBQADggEPADCCAQoCggEBAM5c6w4NnngTvGNWcJzbo0Kklp+kvUNQNgGu\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 "myvz826qPp07HTSyJrIcgFnuYDR0Nd130Ot9u5osqpQhHTvolxDE87Tii8i3hJSj\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67 "TTY9K0ZwGb4AZ6QkuyMXS1jtOY657HqjpGZqT/2Syh0i7dM/hqSXFw0SPbyq+W1H\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68 "SVFWa1CTkPywFWAzwdr5WKah77uZ1dxWqgPgUdcZOiIQtLRp5n3fg40Nwso5YdwS\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
69 "64+ebBX1pkhrCQ8AGc8O61Ep1JTXcO7jqQmPgzjiN+FeostI1Dp73S3MqleTAHjR\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
70 "hqZ77VF7nkroMM9btMHJBaxnfwc2ewULUJwnuOiGWrvMq/9Z4J8CAwEAAaOB/DCB\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
71 "+TAdBgNVHQ4EFgQUkqpVn7N3gmiJ7X5zQ2bki+7qv4UwgckGA1UdIwSBwTCBvoAU\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
72 "kqpVn7N3gmiJ7X5zQ2bki+7qv4WhgZqkgZcwgZQxCzAJBgNVBAYTAkpQMQ4wDAYD\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
73 "VQQIDAVUb2t5bzEQMA4GA1UEBwwHS29nYW5laTENMAsGA1UECgwEV0lERTEPMA0G\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
74 "A1UECwwGQUFBIFdHMR8wHQYDVQQDDBZjaGF2cm91eC5jb3dhZGRpY3Qub3JnMSIw\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
75 "IAYJKoZIhvcNAQkBFhNzZGVjdWdpc0BuaWN0LmdvLmpwggkA0qAPB2UNhAMwDAYD\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76 "VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAJy0XLk8j8YLSTt2/VMy9TAUx\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77 "esXUiZj0Ung+gkr7A1K0NnwYxDzG2adMhf13upHoydu2ErLMmD6F77x+QuY/q7nc\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78 "ZvO0tvcoAP6ToSDwiypU5dnTmnfkgwVwzFkNCi1sGRosEm8c/c/8MfK0I0nVdj1/\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79 "BIkIG7tTDVi9JvkWYl0UlSKWTZKrntVwCmscfC02DGb+GoLbO9+QmiNM5Y3yOYZ4\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
80 "Pc7SSoKLL0rwJBmpPNs7boYsweeSuCAVu0shRfgC90odXcej2EN5ETfCuU1evXNW\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
81 "5cA+zZsDK/nWJwxBaW0CxAHX579FElFWlK4+BnzhZRdDhmJDnN5dh4ekJGM6Lg==\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
82 "-----END CERTIFICATE-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
83
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
84 /* Client:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
85 Certificate:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
86 Data:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
87 Version: 3 (0x2)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
88 Serial Number: 5 (0x5)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
89 Signature Algorithm: sha1WithRSAEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
90 Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
91 Validity
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
92 Not Before: Oct 27 04:04:05 2009 GMT
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
93 Not After : Oct 25 04:04:05 2019 GMT
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
94 Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=client.test/emailAddress=client@test
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
95 Subject Public Key Info:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
96 Public Key Algorithm: rsaEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
97 RSA Public Key: (1024 bit)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
98 Modulus (1024 bit):
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
99 00:bd:eb:50:1e:9d:7a:cd:9d:bb:e7:bc:4e:38:4a:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
100 b2:cc:9e:b4:89:77:01:ef:d1:c6:19:29:00:fe:ce:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
101 3c:62:05:13:b1:8c:ff:31:7a:0f:c1:2e:4b:3c:0c:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
102 40:1e:36:4e:76:da:0a:64:43:fc:1e:ea:0c:97:b2:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
103 57:9c:9c:8c:90:bd:eb:23:7b:b8:b7:5c:03:ed:6f:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
104 48:55:8a:88:08:38:c5:cd:33:b7:ab:a8:3a:6f:7f:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
105 13:10:65:a5:50:b9:f4:8b:cc:2e:e9:79:58:a6:11:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
106 f0:58:45:41:ef:36:b3:35:cb:14:ec:82:0c:ad:11:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
107 6a:ea:64:ef:28:a2:6e:47:45
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
108 Exponent: 65537 (0x10001)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
109 X509v3 extensions:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
110 X509v3 Basic Constraints:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
111 CA:FALSE
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
112 Netscape Comment:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
113 OpenSSL Generated Certificate
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
114 X509v3 Subject Key Identifier:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
115 BE:B3:89:4F:9D:8F:6C:20:C4:D0:3E:6A:05:11:82:50:54:49:70:A2
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
116 X509v3 Authority Key Identifier:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
117 keyid:92:AA:55:9F:B3:77:82:68:89:ED:7E:73:43:66:E4:8B:EE:EA:BF:85
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
119 Signature Algorithm: sha1WithRSAEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
120 a3:88:f5:15:b5:ad:20:60:a1:85:19:3f:b9:5e:1e:be:31:7f:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
121 84:7a:c2:18:3a:63:6a:67:1f:46:86:4d:10:d6:1d:ad:a2:c8:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
122 0b:95:33:fa:e4:05:f4:b8:70:34:77:f7:85:6e:70:46:ac:39:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
123 54:a9:5f:ea:5e:d1:33:bb:c9:a3:42:81:41:90:25:b5:92:8b:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
124 e8:6e:3e:97:06:dd:9a:cc:29:61:34:5a:d3:1c:5d:ad:d1:a3:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
125 eb:6a:47:b4:d0:c2:17:89:e1:e2:2d:36:18:50:1a:e7:d4:fc:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
126 38:2e:47:0b:39:50:87:2f:aa:07:64:f8:9a:4d:47:01:da:10:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
127 d8:97:c7:a6:13:bc:0e:ca:63:c1:f2:09:fb:f8:6a:a4:5f:08:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
128 b5:ad:ed:4f:71:b9:89:7f:43:27:85:72:e7:8d:a8:4a:cc:f6:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
129 36:ca:8a:ae:82:b5:a8:42:41:99:87:84:7c:f0:90:fd:ca:96:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
130 37:a2:e0:d9:fa:dd:a4:c9:f1:50:b7:e5:e6:8f:af:83:8c:23:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
131 b6:20:cc:66:e3:08:60:13:02:8f:42:3a:07:91:a7:38:b2:72:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
132 16:fd:bd:a9:60:f0:e2:9f:23:f3:c0:99:e3:17:bc:00:7c:b3:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
133 89:9c:ea:fa:3e:f6:69:a1:98:c2:ec:46:da:70:b6:f9:c3:93:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
134 a7:fc:36:dd
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
135 */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136 static char client_cert_data[] ="-----BEGIN CERTIFICATE-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
137 "MIIDiTCCAnGgAwIBAgIBBTANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
138 "DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
139 "MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 "cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI3\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141 "MDQwNDA1WhcNMTkxMDI1MDQwNDA1WjCBgTELMAkGA1UEBhMCSlAxDjAMBgNVBAgM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142 "BVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURFMQ8wDQYDVQQL\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 "DAZBQUEgV0cxFDASBgNVBAMMC2NsaWVudC50ZXN0MRowGAYJKoZIhvcNAQkBFgtj\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 "bGllbnRAdGVzdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAvetQHp16zZ27\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
145 "57xOOEqyzJ60iXcB79HGGSkA/s48YgUTsYz/MXoPwS5LPAxAHjZOdtoKZEP8HuoM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 "l7JXnJyMkL3rI3u4t1wD7W9IVYqICDjFzTO3q6g6b38TEGWlULn0i8wu6XlYphHw\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147 "WEVB7zazNcsU7IIMrRFq6mTvKKJuR0UCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglg\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 "hkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0O\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149 "BBYEFL6ziU+dj2wgxNA+agURglBUSXCiMB8GA1UdIwQYMBaAFJKqVZ+zd4Joie1+\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150 "c0Nm5Ivu6r+FMA0GCSqGSIb3DQEBBQUAA4IBAQCjiPUVta0gYKGFGT+5Xh6+MX+E\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 "esIYOmNqZx9Ghk0Q1h2tosgLlTP65AX0uHA0d/eFbnBGrDlUqV/qXtEzu8mjQoFB\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 "kCW1kovobj6XBt2azClhNFrTHF2t0aPrake00MIXieHiLTYYUBrn1Pw4LkcLOVCH\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 "L6oHZPiaTUcB2hDYl8emE7wOymPB8gn7+GqkXwi1re1PcbmJf0MnhXLnjahKzPY2\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 "yoqugrWoQkGZh4R88JD9ypY3ouDZ+t2kyfFQt+Xmj6+DjCO2IMxm4whgEwKPQjoH\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155 "kac4snIW/b2pYPDinyPzwJnjF7wAfLOJnOr6PvZpoZjC7EbacLb5w5On/Dbd\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 "-----END CERTIFICATE-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
157 static char client_priv_data[] ="-----BEGIN RSA PRIVATE KEY-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
158 "MIICXgIBAAKBgQC961AenXrNnbvnvE44SrLMnrSJdwHv0cYZKQD+zjxiBROxjP8x\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 "eg/BLks8DEAeNk522gpkQ/we6gyXslecnIyQvesje7i3XAPtb0hViogIOMXNM7er\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
160 "qDpvfxMQZaVQufSLzC7peVimEfBYRUHvNrM1yxTsggytEWrqZO8oom5HRQIDAQAB\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
161 "AoGBAIYnsOLPby3LnC5n8AEHkyHDgdgQvsd/MSYYtuFHIZRD7dNfu+xhQru9TdvO\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 "84Pj7K07/FczRuc3gUmu6wBv/UIP9To15RHZh+/n537nybGus5S4IYKVvap477To\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
163 "0rQDf9ec27iw77gxb7moQ9Otuxwbv0h0Z+1EVLI8d8jHOq0BAkEA9YNr0R+7KXBS\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164 "48yT43g5HpOFkTZzNXWVdpSvYGneb56wslk5Eatp235I4uz/a7Rej5v99W0M3nSe\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 "/AgHfYn75QJBAMYH/pBx/WkrLj+pPaARlNwInCIC5zUhr6B0IKCt2tvy5eyuc5sd\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 "AoTFaU+cSI+ZqsRzY8jMKkonktxBg48oJ+ECQQCt4AtlqcFVkbVCm8pJGQXq/7Ni\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 "qlthiwr1Vkv2TkQ4bPza8pGWT/3Cc2ePPyWN08n8jw+G11p72cAW4mDbqfN5AkEA\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
168 "mNYKrkiLn+NnqlJf8W4gSUGL3uQGtYbuGRQHKnuDckWhFm39YzWcgAQsJvkjN1EN\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 "7thvpsWLzfeE7ODTPGVtgQJATObxYJOt6rms3fAStwuXW3ET77TA1ja4XsUEe5Yu\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 "JpcQOruJb9XwndqzNbL0dSUePb9gFiBCGKYOyreNTTRTmw==\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171 "-----END RSA PRIVATE KEY-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
173 /* Server:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
174 Certificate:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
175 Data:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
176 Version: 3 (0x2)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
177 Serial Number: 4 (0x4)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
178 Signature Algorithm: sha1WithRSAEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
179 Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
180 Validity
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
181 Not Before: Oct 27 04:03:39 2009 GMT
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
182 Not After : Oct 25 04:03:39 2019 GMT
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
183 Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=serv.test/emailAddress=serv@test
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
184 Subject Public Key Info:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
185 Public Key Algorithm: rsaEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
186 RSA Public Key: (1024 bit)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
187 Modulus (1024 bit):
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
188 00:a6:f7:1c:a9:90:5b:fa:c8:f6:a3:04:0c:d0:8b:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
189 45:c3:90:f7:2d:c2:c9:d7:bd:66:8a:7c:1c:51:89:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
190 40:9e:cd:70:57:cb:00:47:a3:e8:76:8b:00:b3:c9:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
191 c3:0d:b1:b9:2a:08:9f:52:92:82:d3:18:c1:d8:d1:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
192 b8:1e:fd:71:fe:23:ec:19:e9:6d:9d:fd:ae:88:bc:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
193 39:44:7a:37:ad:c6:88:d1:64:7c:b1:d4:3c:a9:30:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
194 c4:de:51:02:c4:48:4f:25:3e:2f:93:ae:25:32:66:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
195 9a:dc:f4:44:45:ff:7f:12:49:97:0d:01:8d:13:9a:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
196 d3:8f:9e:2d:62:95:02:0a:c7
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
197 Exponent: 65537 (0x10001)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
198 X509v3 extensions:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
199 X509v3 Basic Constraints:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
200 CA:FALSE
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
201 Netscape Comment:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
202 OpenSSL Generated Certificate
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
203 X509v3 Subject Key Identifier:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
204 0C:33:C4:7F:39:D0:34:FF:F8:61:A1:46:8B:49:1D:A3:57:B3:4D:58
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
205 X509v3 Authority Key Identifier:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
206 keyid:92:AA:55:9F:B3:77:82:68:89:ED:7E:73:43:66:E4:8B:EE:EA:BF:85
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
207
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
208 Signature Algorithm: sha1WithRSAEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
209 87:f5:49:a6:04:f9:98:9a:f1:1a:68:ce:06:ae:4c:0c:08:eb:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
210 ba:98:e7:3f:df:22:7f:35:88:1d:b7:8a:f3:89:a3:68:0d:53:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
211 45:eb:23:a1:dd:6b:dc:b0:80:58:0c:10:0b:49:74:ea:a8:b6:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
212 8c:2e:c6:73:dc:7a:74:c7:59:3e:79:5a:d2:5c:15:0b:f1:d8:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
213 19:37:2a:c0:22:75:10:3f:4c:e9:a1:e0:eb:b2:9e:09:70:3d:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
214 2a:4c:fe:9c:99:36:4b:aa:6c:e1:8b:9c:aa:e1:29:1f:49:6b:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
215 14:db:12:ae:cf:68:4a:dd:03:e1:3b:ad:79:b4:54:84:1d:bb:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
216 ac:45:c4:85:f1:03:65:65:96:23:ae:e7:97:3c:5c:db:ce:55:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
217 34:5d:c3:73:ec:cd:f6:0f:a5:81:5f:c2:ab:a3:42:fa:36:7f:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
218 83:ef:db:0f:cd:62:0b:ea:d9:4f:73:35:68:5f:23:d5:0a:be:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
219 ff:7f:23:9a:af:0d:a5:f8:3e:3a:f0:63:1c:e1:d2:96:81:cf:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
220 7b:5a:6b:d0:9b:67:56:9e:aa:a9:e8:f1:6c:fb:54:2b:1a:f4:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
221 ef:16:5a:be:1d:a9:c8:d6:cc:f7:42:8c:fe:83:2c:84:8c:80:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
222 fb:1c:88:f6:35:1c:ae:43:72:fa:68:30:9c:25:8b:db:2c:84:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
223 87:76:9d:b9
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
224 */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
225 static char server_cert_data[] ="-----BEGIN CERTIFICATE-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
226 "MIIDhDCCAmygAwIBAgIBBDANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
227 "DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
228 "MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
229 "cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI3\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
230 "MDQwMzM5WhcNMTkxMDI1MDQwMzM5WjB9MQswCQYDVQQGEwJKUDEOMAwGA1UECAwF\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
231 "VG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUxDzANBgNVBAsM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
232 "BkFBQSBXRzESMBAGA1UEAwwJc2Vydi50ZXN0MRgwFgYJKoZIhvcNAQkBFglzZXJ2\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
233 "QHRlc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKb3HKmQW/rI9qMEDNCL\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
234 "RcOQ9y3Cyde9Zop8HFGJQJ7NcFfLAEej6HaLALPJww2xuSoIn1KSgtMYwdjRuB79\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
235 "cf4j7BnpbZ39roi8OUR6N63GiNFkfLHUPKkwxN5RAsRITyU+L5OuJTJmmtz0REX/\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
236 "fxJJlw0BjROa04+eLWKVAgrHAgMBAAGjezB5MAkGA1UdEwQCMAAwLAYJYIZIAYb4\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
237 "QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBQM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
238 "M8R/OdA0//hhoUaLSR2jV7NNWDAfBgNVHSMEGDAWgBSSqlWfs3eCaIntfnNDZuSL\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
239 "7uq/hTANBgkqhkiG9w0BAQUFAAOCAQEAh/VJpgT5mJrxGmjOBq5MDAjrupjnP98i\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
240 "fzWIHbeK84mjaA1TResjod1r3LCAWAwQC0l06qi2jC7Gc9x6dMdZPnla0lwVC/HY\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
241 "GTcqwCJ1ED9M6aHg67KeCXA9Kkz+nJk2S6ps4YucquEpH0lrFNsSrs9oSt0D4Tut\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
242 "ebRUhB27rEXEhfEDZWWWI67nlzxc285VNF3Dc+zN9g+lgV/Cq6NC+jZ/g+/bD81i\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
243 "C+rZT3M1aF8j1Qq+/38jmq8Npfg+OvBjHOHSloHPe1pr0JtnVp6qqejxbPtUKxr0\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
244 "7xZavh2pyNbM90KM/oMshIyA+xyI9jUcrkNy+mgwnCWL2yyEh3aduQ==\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
245 "-----END CERTIFICATE-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
246 static char server_priv_data[] ="-----BEGIN RSA PRIVATE KEY-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
247 "MIICXQIBAAKBgQCm9xypkFv6yPajBAzQi0XDkPctwsnXvWaKfBxRiUCezXBXywBH\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
248 "o+h2iwCzycMNsbkqCJ9SkoLTGMHY0bge/XH+I+wZ6W2d/a6IvDlEejetxojRZHyx\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
249 "1DypMMTeUQLESE8lPi+TriUyZprc9ERF/38SSZcNAY0TmtOPni1ilQIKxwIDAQAB\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
250 "AoGAZv3Ddm0P79CLIt9asEFY1VvUvSuMqkGwwPfx1/HcJJkBFYapM4fN22G/Gyf3\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
251 "47ifSWhsLtklTeXVnVMwSh14dJaJQuSEnaFnUUWfjiRbEAXZnMFwAIiaszEZbPap\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
252 "NUNpcGl06FZrphYAMkjOVUfjCjfOZDAvL4JGpo271Zx4l0ECQQDYoFFQpBCPx0PK\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253 "TWUmvatXI/Amo94XkGfofbdeeI8PiAJBO5UI6rmjjIVwsJwO9dQb/IlP1/OnBeJv\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
254 "p9YW5uixAkEAxVAOKu7mpGu0Q/K2iEUUYDX9YHf253kgkdIDF4iZk4Tcecjoxuru\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
255 "fIWu9dMtyDVV+HT2X4cNEnO1/oS3kJII9wJBAJkdwDwiqz4lV6o/yFZ4zAoc8dsu\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
256 "CoZXYMq5SYox5tTQit928OHLn4mVgqBjhPsiEVnyx0+zUZpmE2ZemHm5nxECQHfE\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
257 "FBVzVYRP6+eil7E3XRrZKqc3qiLunxpkA4RxYebtKnaxwLmdOI1VB9InEQ8JcNmT\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
258 "BUkOzJx6p+mJ3XJfchkCQQDWmbMYYJajsjlS4YpdUUj7cBSotA6vtkNVHFr0/ak/\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
259 "S+tLkMNuruaInWizK+BKYTIJLlQDf5u5NTrw41vye5Hv\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
260 "-----END RSA PRIVATE KEY-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
261
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
262 /* Expired:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
263 Certificate:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
264 Data:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
265 Version: 3 (0x2)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
266 Serial Number: 6 (0x6)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
267 Signature Algorithm: sha1WithRSAEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
268 Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
269 Validity
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
270 Not Before: Oct 27 04:06:35 2009 GMT
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
271 Not After : Oct 28 04:06:35 2009 GMT
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
272 Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=expired.test/emailAddress=expired@test
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
273 Subject Public Key Info:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
274 Public Key Algorithm: rsaEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
275 RSA Public Key: (1024 bit)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
276 Modulus (1024 bit):
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
277 00:e3:17:15:54:85:dc:cf:c7:a0:32:4a:49:7d:55:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
278 75:9b:29:15:db:7e:87:17:d9:0e:65:44:53:d7:19:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
279 37:27:c7:c6:fe:c6:dc:72:2b:dc:86:1a:ff:24:6c:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
280 63:3f:75:9c:0a:14:e1:70:06:79:d4:b9:26:d4:68:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
281 4c:28:38:ba:34:60:56:02:3d:94:55:4a:1f:4e:5a:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
282 f0:a5:71:4c:3e:71:69:39:ad:bc:aa:55:35:fb:73:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
283 5b:5f:6c:30:71:8e:8a:b6:a5:06:cc:ee:dd:29:c7:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
284 52:0d:a7:9c:0f:a1:ba:52:11:e2:1b:b9:74:6b:08:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
285 87:11:d2:ec:a9:ac:63:63:4f
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
286 Exponent: 65537 (0x10001)
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
287 X509v3 extensions:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
288 X509v3 Basic Constraints:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
289 CA:FALSE
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
290 Netscape Comment:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
291 OpenSSL Generated Certificate
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
292 X509v3 Subject Key Identifier:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
293 1C:AF:66:42:5B:AD:AA:A5:9B:D9:AE:3A:C1:5A:AC:2F:CC:CE:22:6C
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
294 X509v3 Authority Key Identifier:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
295 keyid:92:AA:55:9F:B3:77:82:68:89:ED:7E:73:43:66:E4:8B:EE:EA:BF:85
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
296
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
297 Signature Algorithm: sha1WithRSAEncryption
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
298 60:8f:55:55:59:82:0f:64:cb:b8:11:c8:44:ce:bf:69:07:0d:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
299 be:c2:34:be:42:6a:78:15:39:9f:be:8a:17:d6:43:42:c9:7c:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
300 f1:6d:5d:aa:c3:1b:4d:b0:f0:b6:73:46:2a:87:cd:55:56:a3:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
301 6d:cc:de:a8:28:6a:53:85:9e:e5:68:b7:3c:f5:72:13:7b:d0:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
302 21:f2:91:49:35:e0:37:1e:28:19:d5:1b:cc:e1:32:1e:7f:b0:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
303 86:df:43:a4:47:0f:29:0b:eb:51:60:9a:f5:ca:50:f4:2d:59:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
304 cd:fc:50:9d:29:ed:45:98:de:a2:5c:d1:b5:7a:34:ad:7a:73:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
305 48:8b:a2:9b:89:8e:4a:2e:2a:04:19:d6:62:6a:0d:f0:96:f2:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
306 f0:d0:22:77:3b:7f:b1:2a:f4:3b:17:47:5e:38:07:09:65:ad:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
307 1d:ea:46:69:6a:96:b6:6b:3b:5c:cc:6e:30:d7:cb:53:69:59:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
308 c2:63:78:2b:03:d4:d4:f7:17:29:99:9a:43:ff:78:0a:af:42:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
309 c5:b3:8d:09:38:5b:30:70:28:c1:97:ab:fd:7f:87:9a:ec:f2:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
310 97:44:ff:f5:b9:41:30:d1:c6:32:98:69:34:c4:39:30:6f:e2:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
311 d3:b2:70:97:66:ee:41:f5:ae:0f:09:f0:ed:60:96:67:a9:8a:
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
312 cd:d6:95:f2
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
313 */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
314 static char expired_cert_data[]="-----BEGIN CERTIFICATE-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
315 "MIIDizCCAnOgAwIBAgIBBjANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
316 "DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
317 "MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
318 "cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI3\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
319 "MDQwNjM1WhcNMDkxMDI4MDQwNjM1WjCBgzELMAkGA1UEBhMCSlAxDjAMBgNVBAgM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
320 "BVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURFMQ8wDQYDVQQL\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
321 "DAZBQUEgV0cxFTATBgNVBAMMDGV4cGlyZWQudGVzdDEbMBkGCSqGSIb3DQEJARYM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
322 "ZXhwaXJlZEB0ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDjFxVUhdzP\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
323 "x6AySkl9VXWbKRXbfocX2Q5lRFPXGTcnx8b+xtxyK9yGGv8kbGM/dZwKFOFwBnnU\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
324 "uSbUaEwoOLo0YFYCPZRVSh9OWvClcUw+cWk5rbyqVTX7c1tfbDBxjoq2pQbM7t0p\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
325 "x1INp5wPobpSEeIbuXRrCIcR0uyprGNjTwIDAQABo3sweTAJBgNVHRMEAjAAMCwG\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
326 "CWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNV\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
327 "HQ4EFgQUHK9mQlutqqWb2a46wVqsL8zOImwwHwYDVR0jBBgwFoAUkqpVn7N3gmiJ\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
328 "7X5zQ2bki+7qv4UwDQYJKoZIhvcNAQEFBQADggEBAGCPVVVZgg9ky7gRyETOv2kH\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
329 "Db7CNL5CangVOZ++ihfWQ0LJfPFtXarDG02w8LZzRiqHzVVWo23M3qgoalOFnuVo\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
330 "tzz1chN70CHykUk14DceKBnVG8zhMh5/sIbfQ6RHDykL61FgmvXKUPQtWc38UJ0p\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
331 "7UWY3qJc0bV6NK16c0iLopuJjkouKgQZ1mJqDfCW8vDQInc7f7Eq9DsXR144Bwll\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
332 "rR3qRmlqlrZrO1zMbjDXy1NpWcJjeCsD1NT3FymZmkP/eAqvQsWzjQk4WzBwKMGX\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
333 "q/1/h5rs8pdE//W5QTDRxjKYaTTEOTBv4tOycJdm7kH1rg8J8O1glmepis3WlfI=\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
334 "-----END CERTIFICATE-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
335 static char expired_priv_data[]="-----BEGIN RSA PRIVATE KEY-----\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
336 "MIICXgIBAAKBgQDjFxVUhdzPx6AySkl9VXWbKRXbfocX2Q5lRFPXGTcnx8b+xtxy\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
337 "K9yGGv8kbGM/dZwKFOFwBnnUuSbUaEwoOLo0YFYCPZRVSh9OWvClcUw+cWk5rbyq\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
338 "VTX7c1tfbDBxjoq2pQbM7t0px1INp5wPobpSEeIbuXRrCIcR0uyprGNjTwIDAQAB\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
339 "AoGASwPoDui9XYHTIGm7xwRA+kVjLAOq+qy//aHJlEeHGcP7r1PfpHNqwH4QhGat\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
340 "jlv6dLYbFld9TVDwS8A8UBkVIPLWnCysd5tF2A4C5akx6ouW6HliW/JheYrgl8AV\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
341 "PVeR3bm91UbnpC0ABVlw87jp1Ovyr60Suo4jsoJz+CyTa2ECQQD0LJWpnwn1jIlR\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
342 "DGkLi7F3E70JJcdhTWzBjGFD+Na+/2ZO0MKLhK+O1WUkKa0oi+e5P1JOnGIpTI8c\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
343 "BJOO415RAkEA7hauapYuqGI/auSPH8/nFB5z1G94RTxo2a5THKcG5MqS/8N3ubFj\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
344 "i2PPS0lEYVjqoHEsZUsMnDmXp6KDKMAfnwJBAIp+T1UqM8fmsmwaEerOjRXxSCNM\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
345 "Hk5+T9Vn/jNDjOpAipLhrbbcx4bIWtmsGd8Jm6Fi3RhhcvvhxLorjlZZeEECQQCf\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
346 "IaPD88sNmlUewdLzhUbCiLQMadCuHflKfRxpyy1tYAQuVFxCTdDlynkzra25ju+K\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
347 "+vmcXjP4evnk/lbBtt+rAkEAgOr4Apgs3nMppngPV5yFx0NDqH2n8PlEAM1Il4Qs\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
348 "IuuK18v0KwlUGAfEEmCiNh1e1qkLmD0CnI2QjYAjcLQUhw==\n"
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
349 "-----END RSA PRIVATE KEY-----\n";
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
350
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
351 /* Unknown CA certificate :
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
352 Certificate:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
353 Data:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
354 Version: 3 (0x2)
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
355 Serial Number: 1 (0x1)
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
356 Signature Algorithm: sha1WithRSAEncryption
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
357 Issuer: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=chavroux.cowaddict.org/emailAddress=sdecugis@nict.go.jp
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
358 Validity
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
359 Not Before: Oct 28 08:04:40 2009 GMT
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
360 Not After : Oct 28 08:04:40 2010 GMT
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
361 Subject: C=JP, ST=Tokyo, L=Koganei, O=WIDE, OU=AAA WG, CN=unknown.cs/emailAddress=unknown@ca
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
362 Subject Public Key Info:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
363 Public Key Algorithm: rsaEncryption
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
364 RSA Public Key: (1024 bit)
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
365 Modulus (1024 bit):
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
366 00:e6:3a:d5:8a:14:c8:15:d0:f0:5c:03:c3:af:33:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
367 51:2c:17:b7:65:ac:45:e8:48:2d:ae:70:fd:7c:79:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
368 3a:c7:80:c8:50:53:d0:19:d8:3a:26:a8:16:4d:4c:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
369 04:17:09:df:69:9b:59:2b:89:c8:e0:60:bb:1d:37:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
370 82:d2:3f:17:39:c9:8f:5d:76:e1:0f:6e:08:9a:8f:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
371 16:4a:ea:83:86:f9:bd:15:14:56:68:87:79:05:f9:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
372 5f:66:11:bd:22:46:26:64:be:57:16:51:66:41:50:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
373 ac:f2:b1:ca:d0:38:11:4b:4c:b2:ee:25:36:6e:d3:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
374 b9:63:72:c4:84:82:1c:2b:27
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
375 Exponent: 65537 (0x10001)
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
376 X509v3 extensions:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
377 X509v3 Basic Constraints:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
378 CA:FALSE
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
379 Netscape Comment:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
380 OpenSSL Generated Certificate
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
381 X509v3 Subject Key Identifier:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
382 BA:5A:9D:D2:B0:4B:72:D6:1F:00:11:0B:B5:7B:59:DF:08:38:81:BE
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
383 X509v3 Authority Key Identifier:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
384 keyid:52:C5:A4:63:B8:DB:AC:F2:92:34:2F:72:56:71:C8:11:8E:76:E6:DF
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
385
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
386 Signature Algorithm: sha1WithRSAEncryption
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
387 90:8f:3b:bd:e3:a1:ca:6a:92:a6:fd:f0:64:ae:46:83:32:35:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
388 61:80:57:8b:30:12:70:02:e1:51:d9:87:c8:af:d9:4b:b9:6d:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
389 bf:ab:86:5f:19:1f:dc:af:84:67:bf:3c:bf:33:f3:7c:c6:81:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
390 7b:e4:e9:26:1d:bc:d6:8c:ab:72:94:7f:85:33:95:d9:24:ec:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
391 fd:7b:d2:fd:50:3e:e5:61:4f:75:51:ae:c6:4a:ec:df:cf:aa:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
392 73:a5:08:f7:f3:9a:40:66:48:f0:8e:9b:43:b1:30:f3:e3:c8:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
393 36:3f:68:36:6a:1c:aa:16:40:49:b4:73:9a:71:f1:17:6c:0b:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
394 d3:e1:a7:b7:40:de:2c:3c:36:7c:d4:dd:d6:94:c9:d7:5f:f5:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
395 ae:35:56:e8:cc:65:9c:bb:3d:e8:7a:ca:0e:ed:78:03:41:cb:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
396 fd:80:81:de:f9:de:b2:14:4b:81:24:36:de:29:c1:06:11:86:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
397 8c:a9:b0:0c:c7:57:cf:79:a7:3a:84:0c:27:dc:86:6d:cb:44:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
398 2d:26:dc:7e:fb:17:d6:b2:3d:31:03:d3:f1:ab:5d:91:5d:94:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
399 e4:94:88:70:96:b3:7c:0f:15:fe:c8:c6:4d:99:37:ab:09:0c:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
400 da:ba:b6:0e:fa:5e:bb:4b:ce:04:21:06:09:a9:2c:27:86:76:
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
401 cc:ee:73:6f
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
402 */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
403 static char notrust_ca_data[] = "-----BEGIN CERTIFICATE-----\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
404 "MIIEqjCCA5KgAwIBAgIJAP3UMghSlH9PMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
405 "VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNV\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
406 "BAoMBFdJREUxDzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
407 "YWRkaWN0Lm9yZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDAe\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
408 "Fw0wOTEwMjgwODAzNDRaFw0xOTEwMjYwODAzNDRaMIGUMQswCQYDVQQGEwJKUDEO\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
409 "MAwGA1UECAwFVG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUx\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
410 "DzANBgNVBAsMBkFBQSBXRzEfMB0GA1UEAwwWY2hhdnJvdXguY293YWRkaWN0Lm9y\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
411 "ZzEiMCAGCSqGSIb3DQEJARYTc2RlY3VnaXNAbmljdC5nby5qcDCCASIwDQYJKoZI\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
412 "hvcNAQEBBQADggEPADCCAQoCggEBALKW9iSUggF5mbvYe1Xk128Csfiijx+fwH5y\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
413 "ZqWrHNt0YG/tZSwyCDMWBLXTeuYsntg5y0mcpsrN8v02tvrPiCzDfRPyz3mG68us\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
414 "DPEEgQ1kqL2Gsti2DUcsdyZcDM+4rgsWRivgOTVyoNimv5f+xgmPYoElkgelLwZK\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
415 "WxGt1VCebOxP3qZA3hSHWE1hJgL4svful7RD1PbwPzidxJKITyAiJoPKWQA9cjSa\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
416 "gVzRQ7S4vmYALJn7xe+dMFRcfAK8RMv7/gJF6Rw7zufW0DIZK98KZs6aL0lmMPVk\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
417 "f31N2uvndf+cjy0n4luwEoXY+TeJZY205lbwHrzR0rH75FSm0RsCAwEAAaOB/DCB\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
418 "+TAdBgNVHQ4EFgQUUsWkY7jbrPKSNC9yVnHIEY525t8wgckGA1UdIwSBwTCBvoAU\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
419 "UsWkY7jbrPKSNC9yVnHIEY525t+hgZqkgZcwgZQxCzAJBgNVBAYTAkpQMQ4wDAYD\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
420 "VQQIDAVUb2t5bzEQMA4GA1UEBwwHS29nYW5laTENMAsGA1UECgwEV0lERTEPMA0G\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
421 "A1UECwwGQUFBIFdHMR8wHQYDVQQDDBZjaGF2cm91eC5jb3dhZGRpY3Qub3JnMSIw\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
422 "IAYJKoZIhvcNAQkBFhNzZGVjdWdpc0BuaWN0LmdvLmpwggkA/dQyCFKUf08wDAYD\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
423 "VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEACANo6IR3OQlQaXHJaprVVDvl\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
424 "oMJC0FRbVCK503sbmWTJL98UqxRdsTZNIL07gXlK0oUKyiNijIXiLG8d5IlUrDxF\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
425 "H/Vsu6s8k3/PpAUVeiO2oygWqvU5NGvt0jg54MrOJKhYYPWrzbmHty+cAXyoNzOR\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
426 "+W5RX6HRQgxvZWQq2Ok46VX622R1nNjFmCBYT7I7/gWG+hkbIAoH6d9sULLjpC+B\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
427 "bI+L/N7ac9/Og8pGIgpUI60Gn5zO93+E+Nhg+1BlcDHGnQD6vFNs8LYp5CCX/Zj1\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
428 "tWFVXZnx58odaU3M4t9/ZQnkZdx9YJIroETbN0PoqlnSagBjgUvbWwn4YCotCA==\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
429 "-----END CERTIFICATE-----\n";
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
430
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
431 static char notrust_cert_data[]="-----BEGIN CERTIFICATE-----\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
432 "MIIDhjCCAm6gAwIBAgIBATANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCSlAx\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
433 "DjAMBgNVBAgMBVRva3lvMRAwDgYDVQQHDAdLb2dhbmVpMQ0wCwYDVQQKDARXSURF\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
434 "MQ8wDQYDVQQLDAZBQUEgV0cxHzAdBgNVBAMMFmNoYXZyb3V4LmNvd2FkZGljdC5v\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
435 "cmcxIjAgBgkqhkiG9w0BCQEWE3NkZWN1Z2lzQG5pY3QuZ28uanAwHhcNMDkxMDI4\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
436 "MDgwNDQwWhcNMTAxMDI4MDgwNDQwWjB/MQswCQYDVQQGEwJKUDEOMAwGA1UECAwF\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
437 "VG9reW8xEDAOBgNVBAcMB0tvZ2FuZWkxDTALBgNVBAoMBFdJREUxDzANBgNVBAsM\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
438 "BkFBQSBXRzETMBEGA1UEAwwKdW5rbm93bi5jczEZMBcGCSqGSIb3DQEJARYKdW5r\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
439 "bm93bkBjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5jrVihTIFdDwXAPD\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
440 "rzNRLBe3ZaxF6EgtrnD9fHk6x4DIUFPQGdg6JqgWTUwEFwnfaZtZK4nI4GC7HTeC\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
441 "0j8XOcmPXXbhD24Imo8WSuqDhvm9FRRWaId5BflfZhG9IkYmZL5XFlFmQVCs8rHK\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
442 "0DgRS0yy7iU2btO5Y3LEhIIcKycCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgB\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
443 "hvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYE\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
444 "FLpandKwS3LWHwARC7V7Wd8IOIG+MB8GA1UdIwQYMBaAFFLFpGO426zykjQvclZx\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
445 "yBGOdubfMA0GCSqGSIb3DQEBBQUAA4IBAQCQjzu946HKapKm/fBkrkaDMjVhgFeL\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
446 "MBJwAuFR2YfIr9lLuW2/q4ZfGR/cr4Rnvzy/M/N8xoF75OkmHbzWjKtylH+FM5XZ\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
447 "JOz9e9L9UD7lYU91Ua7GSuzfz6pzpQj385pAZkjwjptDsTDz48g2P2g2ahyqFkBJ\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
448 "tHOacfEXbAvT4ae3QN4sPDZ81N3WlMnXX/WuNVbozGWcuz3oesoO7XgDQcv9gIHe\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
449 "+d6yFEuBJDbeKcEGEYaMqbAMx1fPeac6hAwn3IZty0QtJtx++xfWsj0xA9Pxq12R\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
450 "XZTklIhwlrN8DxX+yMZNmTerCQzaurYO+l67S84EIQYJqSwnhnbM7nNv\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
451 "-----END CERTIFICATE-----\n";
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
452 static char notrust_priv_data[]="-----BEGIN RSA PRIVATE KEY-----\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
453 "MIICXQIBAAKBgQDmOtWKFMgV0PBcA8OvM1EsF7dlrEXoSC2ucP18eTrHgMhQU9AZ\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
454 "2DomqBZNTAQXCd9pm1kricjgYLsdN4LSPxc5yY9dduEPbgiajxZK6oOG+b0VFFZo\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
455 "h3kF+V9mEb0iRiZkvlcWUWZBUKzyscrQOBFLTLLuJTZu07ljcsSEghwrJwIDAQAB\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
456 "AoGAeRec1SGVE5Rvt5XrSK0vFofq2DlCE6hTDpszWFLTDbe4pDdRDybhfw+Nm15O\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
457 "EGgK8BrbTcEMvKdkAzv9POQeLDE8JImgesHZFxN3jnkK+b762BGRDt57DzvMJsfj\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
458 "1LBle+UBnZB1CvjrINvu+tNMVPlUpjIstbpMq0D+s01+ijECQQD8MHTv/M+Uc86u\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
459 "1SFywgs+eQPQ8g0OoTLxzqo6YhW8FtwLjoRCZx2TNQS5gYBuQrixd/yE0Spfv9aS\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
460 "UtlAaOc1AkEA6bVufggHVHcgiWqS8CHzb6g/GRxQixVshOsoVLMkCSz04zlwIfXF\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
461 "c03hh5RJVv7jmuBmhHbayujMgvinw75oawJAQb9oXUDt5Wgj1FTgeYi5YbovEoRo\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
462 "fw3ruDsHCl2UCQt0ptarCJzVixFhf/ORRi3C9RGxFfdqMrhS+qb62N4AmQJBALYU\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
463 "T1BLiwJoiWXmLTJ/EP0V9Irov2uMtm5cE6DhrJqlduksz8r1gu7RZ3tMsVLg5Iy+\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
464 "dcCQJOffNa54caQUTZ8CQQDTs/70Nr6F6ktrtmtU/S7lIitpQJCu9u/SPyBYPmFZ\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
465 "9Axy6Ee66Php+eWDNP4Ln4axrapD0732wD8DcmGDVHij\n"
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
466 "-----END RSA PRIVATE KEY-----\n";
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
467
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
468 /* Diffie-Hellman parameters, generated with GNUTLS certtool:
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
469 certtool --generate-dh-params
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
470 Generator: 06
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
471
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
472 Prime: ea:c3:75:0b:32:cf:d9:17:98:5c:da:d1
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
473 e0:1d:b9:7c:be:29:60:b0:6f:68:a9:f6
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
474 8d:75:05:59:69:04:ae:39:7c:2b:74:04
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
475 3c:e2:da:28:8a:9b:93:aa:67:05:a7:3e
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
476 06:3e:0d:31:63:88:55:ad:5a:bd:41:22
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
477 b7:58:a7:45:b3:d5:03:ad:de:3c:8d:69
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
478 42:bf:84:3d:c1:90:e7:39:6a:4b:87:01
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
479 19:e5:f3:a4:e5:8e:e2:45:d5:0c:6b:17
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
480 22:2b:2e:50:83:91:0c:5b:82:fc:72:27
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
481 49:3b:9f:29:11:53:c7:90:b8:8d:87:73
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
482 1a:7b:05:ab:cb:30:59:16:71:30:60:1b
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
483 4c:80:15:3a:a2:d3:47:b7:4a:61:de:64
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
484 7e:79:de:88:53:b7:7a:c6:a2:9a:bb:55
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
485 40:2d:7a:71:c7:41:b5:29:df:d7:5c:fb
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
486 42:e4:d8:5e:0b:99:d3:3c:93:0f:33:51
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
487 8b:f4:60:e4:c5:b5:58:21:c0:51:c4:43
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
488 25:7c:37:fe:5c:d3:62:6c:2a:af:a7:2a
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
489 82:d5:d3:e2:bb:5d:ad:84:15:f6:78:d9
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
490 d5:a8:f7:f0:48:5c:8d:e0:3d:04:ac:cf
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
491 aa:34:3f:5d:f2:0d:3d:ee:ec:b8:d8:e8
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
492 ad:dc:d3:40:59:a0:fd:45:62:47:63:c0
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
493 bd:f5:df:8b
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
494 */
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
495 static char dh_params_data[] = "-----BEGIN DH PARAMETERS-----\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
496 "MIIBCAKCAQEA6sN1CzLP2ReYXNrR4B25fL4pYLBvaKn2jXUFWWkErjl8K3QEPOLa\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
497 "KIqbk6pnBac+Bj4NMWOIVa1avUEit1inRbPVA63ePI1pQr+EPcGQ5zlqS4cBGeXz\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
498 "pOWO4kXVDGsXIisuUIORDFuC/HInSTufKRFTx5C4jYdzGnsFq8swWRZxMGAbTIAV\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
499 "OqLTR7dKYd5kfnneiFO3esaimrtVQC16ccdBtSnf11z7QuTYXguZ0zyTDzNRi/Rg\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
500 "5MW1WCHAUcRDJXw3/lzTYmwqr6cqgtXT4rtdrYQV9njZ1aj38EhcjeA9BKzPqjQ/\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
501 "XfINPe7suNjordzTQFmg/UViR2PAvfXfiwIBBg==\n"
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
502 "-----END DH PARAMETERS-----\n";
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
503
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
504
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
505 /* List server endpoints */
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
506 static struct fd_list eps = FD_LIST_INITIALIZER(eps);
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
507
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
508 /* Pass parameters to the connect thread */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
509 struct connect_flags {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
510 int proto;
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
511 int expect_failure; /* 0 or 1 */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
512 };
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
513
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
514 /* Client's side of the connection established from a separate thread */
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
515 static void * connect_thr(void * arg)
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
516 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
517 struct connect_flags * cf = arg;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
518 struct cnxctx * cnx = NULL;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
519
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
520 fd_log_threadname ( "testcnx:connect" );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
521
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
522 /* Connect to the server */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
523 switch (cf->proto) {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
524 case IPPROTO_TCP:
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
525 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
526 struct fd_endpoint * ep = (struct fd_endpoint *)(eps.next);
246
6418a188c1b5 getnameinfo is also more sensitive on freeBSD
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 208
diff changeset
527 cnx = fd_cnx_cli_connect_tcp( &ep->sa, sSAlen(&ep->ss) );
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
528 CHECK( 1, (cnx ? 1 : 0) ^ cf->expect_failure );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
529 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
530 break;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
531 #ifndef DISABLE_SCTP
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
532 case IPPROTO_SCTP:
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
533 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
534 cnx = fd_cnx_cli_connect_sctp(0, TEST_PORT, &eps);
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
535 CHECK( 1, (cnx ? 1 : 0) ^ cf->expect_failure );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
536 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
537 break;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
538 #endif /* DISABLE_SCTP */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
539 default:
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
540 CHECK( 0, 1 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
541 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
542
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
543 /* exit */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
544 return cnx;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
545 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
546
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
547 /* Parameters to the handshake thread */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
548 struct handshake_flags {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
549 struct cnxctx * cnx;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
550 gnutls_certificate_credentials_t creds;
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
551 int algo;
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
552 int ret;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
553 };
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
554
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
555 /* Handshake the client's side */
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
556 static void * handshake_thr(void * arg)
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
557 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
558 struct handshake_flags * hf = arg;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
559 fd_log_threadname ( "testcnx:handshake" );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
560 hf->ret = fd_cnx_handshake(hf->cnx, GNUTLS_CLIENT, hf->algo, NULL, hf->creds);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
561 return NULL;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
562 }
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
563
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
564 /* Terminate the client's connection side */
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
565 static void * destroy_thr(void * arg)
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
566 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
567 struct cnxctx * cnx = arg;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
568 fd_log_threadname ( "testcnx:destroy" );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
569 fd_cnx_destroy(cnx);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
570 return NULL;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
571 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
572
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
573 /* Main test routine */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
574 int main(int argc, char *argv[])
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
575 {
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
576 gnutls_datum_t ca = { (uint8_t *)ca_data, sizeof(ca_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
577 gnutls_datum_t server_cert = { (uint8_t *)server_cert_data, sizeof(server_cert_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
578 gnutls_datum_t server_priv = { (uint8_t *)server_priv_data, sizeof(server_priv_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
579 gnutls_datum_t client_cert = { (uint8_t *)client_cert_data, sizeof(client_cert_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
580 gnutls_datum_t client_priv = { (uint8_t *)client_priv_data, sizeof(client_priv_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
581 gnutls_datum_t expired_cert = { (uint8_t *)expired_cert_data, sizeof(expired_cert_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
582 gnutls_datum_t expired_priv = { (uint8_t *)expired_priv_data, sizeof(expired_priv_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
583 gnutls_datum_t notrust_ca = { (uint8_t *)notrust_ca_data, sizeof(notrust_ca_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
584 gnutls_datum_t notrust_cert = { (uint8_t *)notrust_cert_data, sizeof(notrust_cert_data) };
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
585 gnutls_datum_t notrust_priv = { (uint8_t *)notrust_priv_data, sizeof(notrust_priv_data) };
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
586 gnutls_datum_t dh_params = { (uint8_t *)dh_params_data, sizeof(dh_params_data) };
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
587
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
588 /* Listening socket, server side */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
589 struct cnxctx * listener;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
590 #ifndef DISABLE_SCTP
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
591 struct cnxctx * listener_sctp;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
592 #endif /* DISABLE_SCTP */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
593
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
594 /* Server & client connected sockets */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
595 struct cnxctx * server_side;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
596 struct cnxctx * client_side;
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
597
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
598 pthread_t thr;
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
599 int ret, i;
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
600 uint8_t * cer_buf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
601 size_t cer_sz;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
602 uint8_t * rcv_buf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
603 size_t rcv_sz;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
604
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
605 /* First, initialize the daemon modules */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
606 INIT_FD();
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
607
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
608 /* Restrain the # of streams */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
609 fd_g_config->cnf_sctp_str = NB_STREAMS;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
610
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
611 /* Set the CA parameter in the config */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
612 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( fd_g_config->cnf_sec_data.credentials,
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
613 &ca,
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
614 GNUTLS_X509_FMT_PEM), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
615 CHECK( 1, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
616
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
617 #ifdef GNUTLS_VERSION_300
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
618 {
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
619 /* We import these CA in the trust list */
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
620 gnutls_x509_crt_t * calist;
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
621 unsigned int cacount = 0;
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
622
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
623 CHECK_GNUTLS_DO( ret = gnutls_x509_crt_list_import2(&calist, &cacount, &ca, GNUTLS_X509_FMT_PEM,
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
624 GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED), );
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
625 CHECK( 1, cacount );
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
626
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
627 CHECK_GNUTLS_DO( ret = gnutls_x509_trust_list_add_cas (fd_g_config->cnf_sec_data.trustlist, calist, cacount, 0), );
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
628 CHECK( 1, ret );
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
629 }
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
630
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
631 /* Use certificate verification during the handshake */
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
632 gnutls_certificate_set_verify_function (fd_g_config->cnf_sec_data.credentials, fd_tls_verify_credentials_2);
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
633
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
634 #endif /* GNUTLS_VERSION_300 */
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
635
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
636
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
637 /* Set the server credentials (in config) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
638 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( fd_g_config->cnf_sec_data.credentials,
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
639 &server_cert,
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
640 &server_priv,
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
641 GNUTLS_X509_FMT_PEM), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
642 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
643
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
644 /* Set the default priority */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
645 CHECK_GNUTLS_DO( ret = gnutls_priority_init( &fd_g_config->cnf_sec_data.prio_cache, GNUTLS_DEFAULT_PRIORITY, NULL), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
646 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
647
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
648 /* Set default DH params */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
649 CHECK_GNUTLS_DO( ret = gnutls_dh_params_import_pkcs3( fd_g_config->cnf_sec_data.dh_cache, &dh_params, GNUTLS_X509_FMT_PEM), );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
650 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
651
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
652
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
653 /* Initialize the server address (this should give a safe loopback address + port, even on non-standard configs) */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
654 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
655 struct addrinfo hints, *ai, *aip;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
656 memset(&hints, 0, sizeof(hints));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
657 hints.ai_flags = AI_NUMERICSERV;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
658 hints.ai_family = AF_INET;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
659 CHECK( 0, getaddrinfo("localhost", _stringize(TEST_PORT), &hints, &ai) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
660 aip = ai;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
661 while (aip) {
140
34e47f4addf8 Fix broken test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 38
diff changeset
662 CHECK( 0, fd_ep_add_merge( &eps, aip->ai_addr, aip->ai_addrlen, EP_FL_DISC | EP_ACCEPTALL ));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
663 aip = aip->ai_next;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
664 };
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
665 freeaddrinfo(ai);
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
666
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
667 CHECK( 0, FD_IS_LIST_EMPTY(&eps) ? 1 : 0 );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
668 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
669
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
670 /* Start the server(s) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
671 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
672 /* TCP server */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
673 listener = fd_cnx_serv_tcp(TEST_PORT, 0, (struct fd_endpoint *)(eps.next));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
674 CHECK( 1, listener ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
675
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
676 /* Accept incoming clients */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
677 CHECK( 0, fd_cnx_serv_listen(listener));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
678
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
679 #ifndef DISABLE_SCTP
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
680 /* SCTP server */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
681 listener_sctp = fd_cnx_serv_sctp(TEST_PORT, &eps);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
682 CHECK( 1, listener_sctp ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
683
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
684 /* Accept incoming clients */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
685 CHECK( 0, fd_cnx_serv_listen(listener_sctp));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
686 #endif /* DISABLE_SCTP */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
687
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
688 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
689
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
690 /* Initialize the CER message */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
691 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
692 struct msg * cer;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
693 struct dict_object * model = NULL;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
694 struct avp * oh;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
695 union avp_value value;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
696
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
697 /* Find the CER dictionary object */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
698 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &model, ENOENT ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
699
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
700 /* Create the instance */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
701 CHECK( 0, fd_msg_new ( model, 0, &cer ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
702
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
703 /* Now find the Origin-Host dictionary object */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
704 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &model, ENOENT ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
705
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
706 /* Create the instance */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
707 CHECK( 0, fd_msg_avp_new ( model, 0, &oh ) );
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
708 value.os.data = (uint8_t *)"Client.side";
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 393
diff changeset
709 value.os.len = strlen((char *)value.os.data);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
710 CHECK( 0, fd_msg_avp_setvalue ( oh, &value ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
711
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
712 /* Add the AVP */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
713 CHECK( 0, fd_msg_avp_add( cer, MSG_BRW_LAST_CHILD, oh) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
714
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
715 #if 0
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
716 /* For debug: dump the object */
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 859
diff changeset
717 fd_log_debug("Dumping CER");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
718 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, cer, fd_g_config->cnf_dict, 0, 1));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
719 #endif
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
720
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
721 CHECK( 0, fd_msg_bufferize( cer, &cer_buf, &cer_sz ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
722 CHECK( 0, fd_msg_free(cer) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
723 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
724
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
725 /* Simple TCP client / server test (no TLS) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
726 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
727 struct connect_flags cf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
728
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
729 memset(&cf, 0, sizeof(cf));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
730 cf.proto = IPPROTO_TCP;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
731
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
732 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
733 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
734
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
735 /* Accept the connection of the client */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
736 server_side = fd_cnx_serv_accept(listener);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
737 CHECK( 1, server_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
738 CHECK( 0, fd_cnx_start_clear(server_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
739
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
740 /* Retrieve the client connection object */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
741 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
742 CHECK( 1, client_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
743 CHECK( 0, fd_cnx_start_clear(client_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
744
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
745 /* Send a message and receive it */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
746 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
747 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
748 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
749 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
750 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
751
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
752 /* Do it in the other direction */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
753 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
754 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
755 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
756 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
757 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
758
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
759 /* Now close the connections */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
760 fd_cnx_destroy(client_side);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
761 fd_cnx_destroy(server_side);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
762 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
763
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
764 #ifndef DISABLE_SCTP
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
765 /* Simple SCTP client / server test (no TLS) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
766 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
767 struct connect_flags cf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
768
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
769 memset(&cf, 0, sizeof(cf));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
770 cf.proto = IPPROTO_SCTP;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
771
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
772 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
773 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
774
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
775 /* Accept the connection of the client */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
776 server_side = fd_cnx_serv_accept(listener_sctp);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
777 CHECK( 1, server_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
778
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
779 /* Retrieve the client connection object */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
780 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
781 CHECK( 1, client_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
782
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
783 CHECK( 0, fd_cnx_start_clear(server_side, 1) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
784
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
785 /* Send a message and receive it */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
786 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
787 CHECK( EINVAL, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
788 CHECK( 0, fd_cnx_start_clear(client_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
789 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
790 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
791 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
792 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
793
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
794 /* Do it in the other direction */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
795 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
796 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
797 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
798 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
799 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
800
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
801 /* Do it one more time to use another stream */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
802 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
803 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
804 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
805 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
806 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
807
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
808 /* Now close the connection */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
809 fd_cnx_destroy(client_side);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
810 fd_cnx_destroy(server_side);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
811 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
812 #endif /* DISABLE_SCTP */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
813
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
814 /* TCP Client / server emulating old Diameter behavior (handshake after 1 message exchange) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
815 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
816 struct connect_flags cf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
817 struct handshake_flags hf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
818
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
819 memset(&cf, 0, sizeof(cf));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
820 cf.proto = IPPROTO_TCP;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
821
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
822 memset(&hf, 0, sizeof(hf));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
823
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
824 /* Initialize remote certificate */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
825 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
826 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
827 /* Set the CA */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
828 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
829 CHECK( 1, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
830 /* Set the key */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
831 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
832 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
833
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
834 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
835 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
836
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
837 /* Accept the connection of the client */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
838 server_side = fd_cnx_serv_accept(listener);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
839 CHECK( 1, server_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
840
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
841 /* Retrieve the client connection object */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
842 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
843 CHECK( 1, client_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
844 hf.cnx = client_side;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
845
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
846 /* In legacy Diameter, we exchange first one message (CER / CEA) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
847
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
848 CHECK( 0, fd_cnx_start_clear(server_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
849 CHECK( 0, fd_cnx_start_clear(client_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
850
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
851 /* Send a message and receive it */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
852 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
853 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
854 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
855 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
856 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
857
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
858 /* And the supposed reply */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
859 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
860 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
861 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
862 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
863 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
864
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
865 /* At this point in legacy Diameter we start the handshake */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
866 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
867 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT /* No impact on TCP */, NULL, NULL) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
868 CHECK( 0, pthread_join(thr, NULL) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
869 CHECK( 0, hf.ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
870
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
871 /* Send a few TLS protected message, and replies */
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
872 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
873 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
874 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
875 CHECK( cer_sz, rcv_sz );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
876 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
877 free(rcv_buf);
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
878
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
879 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
880 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
881 CHECK( cer_sz, rcv_sz );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
882 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
883 free(rcv_buf);
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
884 }
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
885
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
886
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
887 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
888 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
889 fd_cnx_destroy(server_side);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
890 CHECK( 0, pthread_join(thr, NULL) );
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
891
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
892 /* Free the credentials */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
893 gnutls_certificate_free_keys(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
894 gnutls_certificate_free_cas(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
895 gnutls_certificate_free_credentials(hf.creds);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
896 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
897
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
898 #ifndef DISABLE_SCTP
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
899 /* SCTP Client / server emulating old Diameter behavior (handshake after 1 message exchange) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
900 {
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
901 struct connect_flags cf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
902 struct handshake_flags hf;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
903
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
904 memset(&cf, 0, sizeof(cf));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
905 cf.proto = IPPROTO_SCTP;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
906
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
907 memset(&hf, 0, sizeof(hf));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
908 hf.algo = ALGO_HANDSHAKE_3436; /* this is mandatory for old TLS mechanism */
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
909
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
910 /* Initialize remote certificate */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
911 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
912 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
913 /* Set the CA */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
914 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
915 CHECK( 1, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
916 /* Set the key */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
917 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
918 CHECK( GNUTLS_E_SUCCESS, ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
919
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
920 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
921 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
922
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
923 /* Accept the connection of the client */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
924 server_side = fd_cnx_serv_accept(listener_sctp);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
925 CHECK( 1, server_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
926
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
927 /* Retrieve the client connection object */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
928 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
929 CHECK( 1, client_side ? 1 : 0 );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
930 hf.cnx = client_side;
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
931
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
932 /* In legacy Diameter, we exchange first one message (CER / CEA) */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
933
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
934 CHECK( 0, fd_cnx_start_clear(server_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
935 CHECK( 0, fd_cnx_start_clear(client_side, 0) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
936
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
937 /* Send a message and receive it */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
938 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
939 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
940 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
941 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
942 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
943
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
944 /* And the supposed reply */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
945 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
946 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
947 CHECK( cer_sz, rcv_sz );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
948 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
949 free(rcv_buf);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
950
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
951 /* At this point in legacy Diameter we start the handshake */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
952 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
953 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_3436, NULL, NULL) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
954 CHECK( 0, pthread_join(thr, NULL) );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
955 CHECK( 0, hf.ret );
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
956
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
957 /* Send a few TLS protected message, and replies */
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
958 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
959 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
960 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
961 CHECK( cer_sz, rcv_sz );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
962 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
963 free(rcv_buf);
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
964
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
965 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
966 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
967 CHECK( cer_sz, rcv_sz );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
968 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
969 free(rcv_buf);
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
970 }
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
971
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
972
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
973 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
974 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
975 fd_cnx_destroy(server_side);
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
976 CHECK( 0, pthread_join(thr, NULL) );
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
977
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
978 /* Free the credentials */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
979 gnutls_certificate_free_keys(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
980 gnutls_certificate_free_cas(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
981 gnutls_certificate_free_credentials(hf.creds);
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
982 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
983 #endif /* DISABLE_SCTP */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
984
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
985 /* TCP Client / server emulating new Diameter behavior (handshake at connection directly) */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
986 {
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
987 struct connect_flags cf;
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
988 struct handshake_flags hf;
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
989
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
990 memset(&cf, 0, sizeof(cf));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
991 cf.proto = IPPROTO_TCP;
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
992
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
993 memset(&hf, 0, sizeof(hf));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
994
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
995 /* Initialize remote certificate */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
996 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
997 CHECK( GNUTLS_E_SUCCESS, ret );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
998 /* Set the CA */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
999 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1000 CHECK( 1, ret );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1001 /* Set the key */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1002 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1003 CHECK( GNUTLS_E_SUCCESS, ret );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1004
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1005 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1006 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1007
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1008 /* Accept the connection of the client */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1009 server_side = fd_cnx_serv_accept(listener);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1010 CHECK( 1, server_side ? 1 : 0 );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1011
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1012 /* Retrieve the client connection object */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1013 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1014 CHECK( 1, client_side ? 1 : 0 );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1015 hf.cnx = client_side;
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1016
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1017 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1018 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1019 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1020 CHECK( 0, pthread_join(thr, NULL) );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1021 CHECK( 0, hf.ret );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1022
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1023 /* Send a few TLS protected message, and replies */
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1024 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1025 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1026 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1027 CHECK( cer_sz, rcv_sz );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1028 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1029 free(rcv_buf);
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1030
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1031 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1032 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1033 CHECK( cer_sz, rcv_sz );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1034 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1035 free(rcv_buf);
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1036 }
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1037
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1038 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1039 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
30
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1040 fd_cnx_destroy(server_side);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1041 CHECK( 0, pthread_join(thr, NULL) );
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1042
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1043 /* Free the credentials */
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1044 gnutls_certificate_free_keys(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1045 gnutls_certificate_free_cas(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1046 gnutls_certificate_free_credentials(hf.creds);
bca243c65b56 Fix some segfaults
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 29
diff changeset
1047 }
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1048
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1049 #ifndef DISABLE_SCTP
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1050
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1051
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1052 /* SCTP Client / server emulating new Diameter behavior (DTLS handshake at connection directly) */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1053 TODO("Enabled after DTLS implementation");
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1054 if (0)
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1055 {
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1056 struct connect_flags cf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1057 struct handshake_flags hf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1058
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1059 memset(&cf, 0, sizeof(cf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1060 cf.proto = IPPROTO_SCTP;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1061
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1062 memset(&hf, 0, sizeof(hf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1063
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1064 /* Initialize remote certificate */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1065 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1066 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1067 /* Set the CA */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1068 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1069 CHECK( 1, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1070 /* Set the key */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1071 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1072 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1073
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1074 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1075 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1076
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1077 /* Accept the connection of the client */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1078 server_side = fd_cnx_serv_accept(listener_sctp);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1079 CHECK( 1, server_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1080
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1081 /* Retrieve the client connection object */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1082 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1083 CHECK( 1, client_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1084 hf.cnx = client_side;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1085
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1086 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1087 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1088 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1089 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1090 CHECK( 0, hf.ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1091
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1092 /* Send a few TLS protected messages, and replies */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1093 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1094 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1095 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1096 CHECK( cer_sz, rcv_sz );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1097 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1098 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1099
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1100 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1101 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1102 CHECK( cer_sz, rcv_sz );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1103 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1104 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1105 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1106
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1107
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1108 /* Now close the connection */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1109 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1110 fd_cnx_destroy(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1111 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1112
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1113 /* Free the credentials */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1114 gnutls_certificate_free_keys(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1115 gnutls_certificate_free_cas(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1116 gnutls_certificate_free_credentials(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1117 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1118
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1119 /* SCTP Client / server emulating old intermediary Diameter behavior (TLS handshake at connection directly) */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1120 {
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1121 struct connect_flags cf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1122 struct handshake_flags hf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1123
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1124 memset(&cf, 0, sizeof(cf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1125 cf.proto = IPPROTO_SCTP;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1126
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1127 memset(&hf, 0, sizeof(hf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1128 hf.algo = ALGO_HANDSHAKE_3436; /* this is mandatory for old TLS mechanism */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1129
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1130 /* Initialize remote certificate */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1131 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1132 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1133 /* Set the CA */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1134 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1135 CHECK( 1, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1136 /* Set the key */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1137 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1138 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1139
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1140 /* Start the client thread */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1141 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1142
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1143 /* Accept the connection of the client */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1144 server_side = fd_cnx_serv_accept(listener_sctp);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1145 CHECK( 1, server_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1146
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1147 /* Retrieve the client connection object */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1148 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1149 CHECK( 1, client_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1150 hf.cnx = client_side;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1151
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1152 /* Start the handshake directly */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1153 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1154 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_3436, NULL, NULL) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1155 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1156 CHECK( 0, hf.ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1157
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1158 /* Send a few TLS protected messages, and replies */
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1159 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1160 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1161 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1162 CHECK( cer_sz, rcv_sz );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1163 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1164 free(rcv_buf);
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1165
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1166 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1167 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1168 CHECK( cer_sz, rcv_sz );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1169 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1170 free(rcv_buf);
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1171 }
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1172
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1173
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1174 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1175 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1176 fd_cnx_destroy(server_side);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1177 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1178
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1179 /* Free the credentials */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1180 gnutls_certificate_free_keys(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1181 gnutls_certificate_free_cas(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1182 gnutls_certificate_free_credentials(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1183 }
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1184 #endif /* DISABLE_SCTP */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1185
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1186 /* Test with different number of streams between server and client */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1187 #ifndef DISABLE_SCTP
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1188 /* DTLS / SCTP style */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1189 TODO("Enabled after DTLS implementation");
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1190 if (0)
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1191 {
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1192 struct connect_flags cf;
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1193 struct handshake_flags hf;
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1194
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1195 memset(&cf, 0, sizeof(cf));
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1196 cf.proto = IPPROTO_SCTP;
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1197
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1198 memset(&hf, 0, sizeof(hf));
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1199
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1200 /* Initialize remote certificate */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1201 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1202 CHECK( GNUTLS_E_SUCCESS, ret );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1203 /* Set the CA */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1204 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1205 CHECK( 1, ret );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1206 /* Set the key */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1207 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1208 CHECK( GNUTLS_E_SUCCESS, ret );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1209
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1210 /* Start the client thread with more streams than the server */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1211 fd_g_config->cnf_sctp_str = 2 * NB_STREAMS;
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1212 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1213
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1214 /* Accept the connection of the client */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1215 server_side = fd_cnx_serv_accept(listener_sctp);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1216 CHECK( 1, server_side ? 1 : 0 );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1217
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1218 /* Retrieve the client connection object */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1219 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1220 CHECK( 1, client_side ? 1 : 0 );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1221 hf.cnx = client_side;
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1222
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1223 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1224 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1225 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1226 CHECK( 0, pthread_join(thr, NULL) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1227 CHECK( 0, hf.ret );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1228
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1229 /* Send a few TLS protected message, and replies */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1230 for (i = 0; i < 4 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1231 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1232 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1233 CHECK( cer_sz, rcv_sz );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1234 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1235 free(rcv_buf);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1236
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1237 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1238 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1239 CHECK( cer_sz, rcv_sz );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1240 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1241 free(rcv_buf);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1242 }
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1243
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1244 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1245 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1246 fd_cnx_destroy(server_side);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1247 CHECK( 0, pthread_join(thr, NULL) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1248
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1249 /* Do the same test but with more streams on the server this time */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1250 fd_g_config->cnf_sctp_str = NB_STREAMS / 2;
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1251 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1252
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1253 /* Accept the connection of the client */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1254 server_side = fd_cnx_serv_accept(listener_sctp);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1255 CHECK( 1, server_side ? 1 : 0 );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1256
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1257 /* Retrieve the client connection object */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1258 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1259 CHECK( 1, client_side ? 1 : 0 );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1260 hf.cnx = client_side;
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1261
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1262 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1263 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1264 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1265 CHECK( 0, pthread_join(thr, NULL) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1266 CHECK( 0, hf.ret );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1267
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1268 /* Send a few TLS protected message, and replies */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1269 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1270 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1271 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1272 CHECK( cer_sz, rcv_sz );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1273 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1274 free(rcv_buf);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1275
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1276 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1277 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1278 CHECK( cer_sz, rcv_sz );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1279 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1280 free(rcv_buf);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1281 }
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1282
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1283 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1284 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1285 fd_cnx_destroy(server_side);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1286 CHECK( 0, pthread_join(thr, NULL) );
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1287
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1288
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1289 /* Free the credentials */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1290 gnutls_certificate_free_keys(hf.creds);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1291 gnutls_certificate_free_cas(hf.creds);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1292 gnutls_certificate_free_credentials(hf.creds);
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1293 }
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1294
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1295 /* TLS / SCTP style */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1296 {
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1297 struct connect_flags cf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1298 struct handshake_flags hf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1299
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1300 memset(&cf, 0, sizeof(cf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1301 cf.proto = IPPROTO_SCTP;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1302
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1303 memset(&hf, 0, sizeof(hf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1304 hf.algo = ALGO_HANDSHAKE_3436;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1305
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1306 /* Initialize remote certificate */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1307 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1308 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1309 /* Set the CA */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1310 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1311 CHECK( 1, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1312 /* Set the key */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1313 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1314 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1315
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1316 /* Start the client thread with more streams than the server */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1317 fd_g_config->cnf_sctp_str = 2 * NB_STREAMS;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1318 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1319
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1320 /* Accept the connection of the client */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1321 server_side = fd_cnx_serv_accept(listener_sctp);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1322 CHECK( 1, server_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1323
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1324 /* Retrieve the client connection object */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1325 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1326 CHECK( 1, client_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1327 hf.cnx = client_side;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1328
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1329 /* Start the handshake directly */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1330 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1331 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_3436, NULL, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1332 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1333 CHECK( 0, hf.ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1334
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1335 /* Send a few TLS protected message, and replies */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1336 for (i = 0; i < 4 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1337 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1338 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1339 CHECK( cer_sz, rcv_sz );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1340 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1341 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1342
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1343 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1344 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1345 CHECK( cer_sz, rcv_sz );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1346 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1347 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1348 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1349
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1350 /* Now close the connection */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1351 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1352 fd_cnx_destroy(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1353 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1354
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1355 /* Do the same test but with more streams on the server this time */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1356 fd_g_config->cnf_sctp_str = NB_STREAMS / 2;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1357 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1358
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1359 /* Accept the connection of the client */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1360 server_side = fd_cnx_serv_accept(listener_sctp);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1361 CHECK( 1, server_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1362
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1363 /* Retrieve the client connection object */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1364 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1365 CHECK( 1, client_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1366 hf.cnx = client_side;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1367
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1368 /* Start the handshake directly */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1369 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1370 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_3436, NULL, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1371 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1372 CHECK( 0, hf.ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1373
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1374 /* Send a few TLS protected message, and replies */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1375 for (i = 0; i < 2 * NB_STREAMS; i++) {
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1376 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1377 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1378 CHECK( cer_sz, rcv_sz );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1379 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1380 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1381
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1382 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1383 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1384 CHECK( cer_sz, rcv_sz );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1385 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1386 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1387 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1388
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1389 /* Now close the connection */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1390 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1391 fd_cnx_destroy(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1392 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1393
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1394
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1395 /* Free the credentials */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1396 gnutls_certificate_free_keys(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1397 gnutls_certificate_free_cas(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1398 gnutls_certificate_free_credentials(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1399 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1400
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1401 #endif /* DISABLE_SCTP */
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1402
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1403
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1404 /* Basic operation tested successfully, now test we detect error conditions */
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1405
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1406 /* Untrusted certificate, TCP */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1407 {
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1408 struct connect_flags cf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1409 struct handshake_flags hf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1410
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1411 memset(&cf, 0, sizeof(cf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1412 cf.proto = IPPROTO_TCP;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1413
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1414 memset(&hf, 0, sizeof(hf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1415
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1416 /* Initialize remote certificate */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1417 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1418 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1419 /* Set the CA */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1420 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &notrust_ca, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1421 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1422 CHECK( 1, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1423 /* Set the key */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1424 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &notrust_cert, &notrust_priv, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1425 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1426
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1427 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1428 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1429
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1430 /* Accept the connection of the client */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1431 server_side = fd_cnx_serv_accept(listener);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1432 CHECK( 1, server_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1433
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1434 /* Retrieve the client connection object */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1435 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1436 CHECK( 1, client_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1437 hf.cnx = client_side;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1438
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1439 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1440 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1441 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1442 fd_cnx_destroy(server_side);
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1443
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1444 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1445
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1446 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1447 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1448 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1449
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1450 /* Free the credentials */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1451 gnutls_certificate_free_keys(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1452 gnutls_certificate_free_cas(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1453 gnutls_certificate_free_credentials(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1454 }
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1455
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1456 /* Same in SCTP */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1457 #ifndef DISABLE_SCTP
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1458 /* DTLS */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1459 TODO("Enabled after DTLS implementation");
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1460 if (0)
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1461 {
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1462 struct connect_flags cf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1463 struct handshake_flags hf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1464
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1465 memset(&cf, 0, sizeof(cf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1466 cf.proto = IPPROTO_SCTP;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1467
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1468 memset(&hf, 0, sizeof(hf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1469
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1470 /* Initialize remote certificate */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1471 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1472 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1473 /* Set the CA */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1474 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &notrust_ca, GNUTLS_X509_FMT_PEM), );
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1475 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1476 CHECK( 1, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1477 /* Set the key */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1478 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &notrust_cert, &notrust_priv, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1479 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1480
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1481 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1482 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1483
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1484 /* Accept the connection of the client */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1485 server_side = fd_cnx_serv_accept(listener_sctp);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1486 CHECK( 1, server_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1487
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1488 /* Retrieve the client connection object */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1489 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1490 CHECK( 1, client_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1491 hf.cnx = client_side;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1492
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1493 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1494 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1495 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1496 fd_cnx_destroy(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1497 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1498
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1499 /* Now close the connection */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1500 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1501 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1502
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1503 /* Free the credentials */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1504 gnutls_certificate_free_keys(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1505 gnutls_certificate_free_cas(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1506 gnutls_certificate_free_credentials(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1507 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1508
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1509 /* TLS */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1510 {
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1511 struct connect_flags cf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1512 struct handshake_flags hf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1513
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1514 memset(&cf, 0, sizeof(cf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1515 cf.proto = IPPROTO_SCTP;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1516
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1517 memset(&hf, 0, sizeof(hf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1518 hf.algo = ALGO_HANDSHAKE_3436;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1519
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1520 /* Initialize remote certificate */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1521 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1522 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1523 /* Set the CA */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1524 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &notrust_ca, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1525 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1526 CHECK( 1, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1527 /* Set the key */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1528 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &notrust_cert, &notrust_priv, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1529 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1530
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1531 /* Start the client thread */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1532 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1533
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1534 /* Accept the connection of the client */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1535 server_side = fd_cnx_serv_accept(listener_sctp);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1536 CHECK( 1, server_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1537
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1538 /* Retrieve the client connection object */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1539 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1540 CHECK( 1, client_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1541 hf.cnx = client_side;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1542
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1543 /* Start the handshake directly */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1544 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1545 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_3436, NULL, NULL) );
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1546 fd_cnx_destroy(server_side);
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1547 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1548
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1549 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1550 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1551 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1552
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1553 /* Free the credentials */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1554 gnutls_certificate_free_keys(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1555 gnutls_certificate_free_cas(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1556 gnutls_certificate_free_credentials(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1557 }
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1558 #endif /* DISABLE_SCTP */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1559
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1560 /* Expired certificate */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1561 {
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1562 struct connect_flags cf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1563 struct handshake_flags hf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1564
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1565 memset(&cf, 0, sizeof(cf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1566 cf.proto = IPPROTO_TCP;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1567
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1568 memset(&hf, 0, sizeof(hf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1569
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1570 /* Initialize remote certificate */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1571 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1572 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1573 /* Set the CA */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1574 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1575 CHECK( 1, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1576 /* Set the key */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1577 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &expired_cert, &expired_priv, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1578 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1579
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1580 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1581 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1582
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1583 /* Accept the connection of the client */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1584 server_side = fd_cnx_serv_accept(listener);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1585 CHECK( 1, server_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1586
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1587 /* Retrieve the client connection object */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1588 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1589 CHECK( 1, client_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1590 hf.cnx = client_side;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1591
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1592 /* Start the handshake directly */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1593 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1594 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1595 fd_cnx_destroy(server_side);
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1596 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1597
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1598 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1599 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1600 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1601
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1602 /* Free the credentials */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1603 gnutls_certificate_free_keys(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1604 gnutls_certificate_free_cas(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1605 gnutls_certificate_free_credentials(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1606 }
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1607
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1608 /* Non matching hostname */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1609
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1610 {
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1611 struct connect_flags cf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1612 struct handshake_flags hf;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1613
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1614 memset(&cf, 0, sizeof(cf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1615 cf.proto = IPPROTO_TCP;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1616
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1617 memset(&hf, 0, sizeof(hf));
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1618
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1619 /* Initialize remote certificate */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1620 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1621 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1622 /* Set the CA */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1623 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1624 CHECK( 1, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1625 /* Set the key */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1626 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1627 CHECK( GNUTLS_E_SUCCESS, ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1628
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1629 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1630 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1631
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1632 /* Accept the connection of the client */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1633 server_side = fd_cnx_serv_accept(listener);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1634 CHECK( 1, server_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1635
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1636 /* Retrieve the client connection object */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1637 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1638 CHECK( 1, client_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1639 hf.cnx = client_side;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1640
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1641 /* Set the correct hostname we expect from the client (in the server) */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1642 fd_cnx_sethostname(server_side, "client.test");
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1643
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1644 /* Start the handshake, check it is successful */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1645 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1646 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1647 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1648 CHECK( 0, hf.ret );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1649
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1650 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1651 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1652 fd_cnx_destroy(server_side);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1653 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1654
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1655 /* Do it again with an invalid hostname */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1656 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1657
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1658 /* Accept the connection of the client */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1659 server_side = fd_cnx_serv_accept(listener);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1660 CHECK( 1, server_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1661
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1662 /* Retrieve the client connection object */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1663 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1664 CHECK( 1, client_side ? 1 : 0 );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1665 hf.cnx = client_side;
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1666
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1667 /* Set the correct hostname we expect from the client (in the server) */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1668 fd_cnx_sethostname(server_side, "nomatch.test");
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1669
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1670 /* Start the handshake, check it is successful */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1671 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1672 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
807
09f8f0c4f4a4 Several changes to support GnuTLS 3.x in a more efficient way
Sebastien Decugis <sdecugis@freediameter.net>
parents: 795
diff changeset
1673 fd_cnx_destroy(server_side);
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1674 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1675
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1676 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1677 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
31
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1678 CHECK( 0, pthread_join(thr, NULL) );
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1679
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1680 /* Free the credentials */
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1681 gnutls_certificate_free_keys(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1682 gnutls_certificate_free_cas(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1683 gnutls_certificate_free_credentials(hf.creds);
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1684 }
26685c67d387 Completed the test and fixed a couple issues
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 30
diff changeset
1685
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1686 /* Test the other functions of the module */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1687 {
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1688 struct connect_flags cf;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1689 struct handshake_flags hf;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1690 char * str;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1691 const gnutls_datum_t *cert_list;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1692 unsigned int cert_list_size;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1693 struct fifo * myfifo = NULL;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1694 struct timespec now;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1695 int ev_code;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1696
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1697 memset(&cf, 0, sizeof(cf));
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1698 cf.proto = IPPROTO_TCP;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1699
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1700 memset(&hf, 0, sizeof(hf));
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1701
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1702 /* Initialize remote certificate */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1703 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1704 CHECK( GNUTLS_E_SUCCESS, ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1705 /* Set the CA */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1706 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1707 CHECK( 1, ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1708 /* Set the key */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1709 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1710 CHECK( GNUTLS_E_SUCCESS, ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1711
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1712 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1713 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1714
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1715 /* Accept the connection of the client */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1716 server_side = fd_cnx_serv_accept(listener);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1717 CHECK( 1, server_side ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1718
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1719 /* Retrieve the client connection object */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1720 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1721 CHECK( 1, client_side ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1722 hf.cnx = client_side;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1723
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1724 /* Start the handshake */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1725 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1726 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1727 CHECK( 0, pthread_join(thr, NULL) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1728 CHECK( 0, hf.ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1729
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1730 /* Test some simple functions */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1731
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1732 /* fd_cnx_getid */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1733 str = fd_cnx_getid(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1734 CHECK( 1, str ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1735 CHECK( 1, (str[0] != '\0') ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1736
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1737 /* fd_cnx_getproto */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1738 i = fd_cnx_getproto(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1739 CHECK( IPPROTO_TCP, i);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1740
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1741 /* fd_cnx_getTLS */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1742 i = fd_cnx_getTLS(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1743 CHECK( 1, i ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1744
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1745 /* fd_cnx_getcred */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1746 CHECK( 0, fd_cnx_getcred(server_side, &cert_list, &cert_list_size) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1747 CHECK( 1, (cert_list_size > 0) ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1748 /* We could also verify that the cert_list really contains the client_cert and ca certificates */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1749
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1750 /* fd_cnx_getremoteid */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1751 str = fd_cnx_getremoteid(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1752 CHECK( 1, str ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1753 CHECK( 1, (str[0] != '\0') ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1754
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1755 /* fd_cnx_recv_setaltfifo */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1756 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
767
c47c16436f71 Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
1757 CHECK( 0, fd_fifo_new(&myfifo, 0) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1758 CHECK( 0, fd_cnx_recv_setaltfifo(server_side, myfifo) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1759 CHECK( 0, clock_gettime(CLOCK_REALTIME, &now) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1760 do {
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1761 CHECK( 0, fd_event_timedget(myfifo, &now, ETIMEDOUT, &ev_code, NULL, (void *)&rcv_buf) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1762 free(rcv_buf);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1763 } while (ev_code != FDEVP_CNX_MSG_RECV);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1764
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1765 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1766 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1767 fd_cnx_destroy(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1768 CHECK( 0, pthread_join(thr, NULL) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1769
859
10f6ce479e1c In Debug builds, this test was failing randomly
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
1770 fd_event_destroy(&myfifo, free);
10f6ce479e1c In Debug builds, this test was failing randomly
Sebastien Decugis <sdecugis@freediameter.net>
parents: 808
diff changeset
1771
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1772 /* Free the credentials */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1773 gnutls_certificate_free_keys(hf.creds);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1774 gnutls_certificate_free_cas(hf.creds);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1775 gnutls_certificate_free_credentials(hf.creds);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1776 }
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1777
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1778 #ifndef DISABLE_SCTP
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1779 /* And re-test with a SCTP connection */
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1780 TODO("Enabled after DTLS implementation");
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1781 if (0)
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1782 {
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1783 struct connect_flags cf;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1784 struct handshake_flags hf;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1785 char * str;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1786 const gnutls_datum_t *cert_list;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1787 unsigned int cert_list_size;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1788 struct fifo * myfifo = NULL;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1789 struct timespec now;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1790 int ev_code;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1791
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1792 memset(&cf, 0, sizeof(cf));
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1793 cf.proto = IPPROTO_SCTP;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1794
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1795 memset(&hf, 0, sizeof(hf));
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1796
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1797 /* Initialize remote certificate */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1798 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1799 CHECK( GNUTLS_E_SUCCESS, ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1800 /* Set the CA */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1801 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1802 CHECK( 1, ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1803 /* Set the key */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1804 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1805 CHECK( GNUTLS_E_SUCCESS, ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1806
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1807 /* Start the client thread */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1808 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1809
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1810 /* Accept the connection of the client */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1811 server_side = fd_cnx_serv_accept(listener_sctp);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1812 CHECK( 1, server_side ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1813
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1814 /* Retrieve the client connection object */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1815 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1816 CHECK( 1, client_side ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1817 hf.cnx = client_side;
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1818
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1819 /* Start the handshake */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1820 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1821 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_DEFAULT, NULL, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1822 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1823 CHECK( 0, hf.ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1824
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1825 /* Test some simple functions */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1826
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1827 /* fd_cnx_getid */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1828 str = fd_cnx_getid(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1829 CHECK( 1, str ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1830 CHECK( 1, (str[0] != '\0') ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1831
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1832 /* fd_cnx_getproto */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1833 i = fd_cnx_getproto(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1834 CHECK( IPPROTO_SCTP, i);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1835
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1836 /* fd_cnx_getTLS */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1837 i = fd_cnx_getTLS(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1838 CHECK( 1, i ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1839
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1840 /* fd_cnx_getcred */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1841 CHECK( 0, fd_cnx_getcred(server_side, &cert_list, &cert_list_size) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1842 CHECK( 1, (cert_list_size > 0) ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1843 /* We could also verify that the cert_list really contains the client_cert and ca certificates */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1844
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1845 /* fd_cnx_getremoteid */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1846 str = fd_cnx_getremoteid(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1847 CHECK( 1, str ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1848 CHECK( 1, (str[0] != '\0') ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1849
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1850 /* fd_cnx_recv_setaltfifo */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1851 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
1181
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1852 CHECK( 0, fd_fifo_new(&myfifo, 0) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1853 CHECK( 0, fd_cnx_recv_setaltfifo(server_side, myfifo) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1854 CHECK( 0, clock_gettime(CLOCK_REALTIME, &now) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1855 do {
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1856 CHECK( 0, fd_event_timedget(myfifo, &now, ETIMEDOUT, &ev_code, NULL, (void *)&rcv_buf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1857 free(rcv_buf);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1858 } while (ev_code != FDEVP_CNX_MSG_RECV);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1859
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1860 /* Now close the connection */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1861 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1862 fd_cnx_destroy(server_side);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1863 CHECK( 0, pthread_join(thr, NULL) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1864
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1865 fd_event_destroy(&myfifo, free);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1866
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1867 /* Free the credentials */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1868 gnutls_certificate_free_keys(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1869 gnutls_certificate_free_cas(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1870 gnutls_certificate_free_credentials(hf.creds);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1871 }
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1872
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1873 /* TLS */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1874 {
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1875 struct connect_flags cf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1876 struct handshake_flags hf;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1877 char * str;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1878 const gnutls_datum_t *cert_list;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1879 unsigned int cert_list_size;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1880 struct fifo * myfifo = NULL;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1881 struct timespec now;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1882 int ev_code;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1883
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1884 memset(&cf, 0, sizeof(cf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1885 cf.proto = IPPROTO_SCTP;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1886
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1887 memset(&hf, 0, sizeof(hf));
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1888 hf.algo = ALGO_HANDSHAKE_3436;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1889
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1890 /* Initialize remote certificate */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1891 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1892 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1893 /* Set the CA */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1894 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1895 CHECK( 1, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1896 /* Set the key */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1897 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1898 CHECK( GNUTLS_E_SUCCESS, ret );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1899
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1900 /* Start the client thread */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1901 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1902
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1903 /* Accept the connection of the client */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1904 server_side = fd_cnx_serv_accept(listener_sctp);
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1905 CHECK( 1, server_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1906
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1907 /* Retrieve the client connection object */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1908 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1909 CHECK( 1, client_side ? 1 : 0 );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1910 hf.cnx = client_side;
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1911
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1912 /* Start the handshake */
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1913 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) );
22de21feec64 Preparing for DTLS support
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1127
diff changeset
1914 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, ALGO_HANDSHAKE_3436, NULL, NULL) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1915 CHECK( 0, pthread_join(thr, NULL) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1916 CHECK( 0, hf.ret );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1917
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1918 /* Test some simple functions */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1919
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1920 /* fd_cnx_getid */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1921 str = fd_cnx_getid(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1922 CHECK( 1, str ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1923 CHECK( 1, (str[0] != '\0') ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1924
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1925 /* fd_cnx_getproto */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1926 i = fd_cnx_getproto(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1927 CHECK( IPPROTO_SCTP, i);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1928
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1929 /* fd_cnx_getTLS */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1930 i = fd_cnx_getTLS(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1931 CHECK( 1, i ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1932
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1933 /* fd_cnx_getcred */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1934 CHECK( 0, fd_cnx_getcred(server_side, &cert_list, &cert_list_size) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1935 CHECK( 1, (cert_list_size > 0) ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1936 /* We could also verify that the cert_list really contains the client_cert and ca certificates */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1937
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1938 /* fd_cnx_getremoteid */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1939 str = fd_cnx_getremoteid(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1940 CHECK( 1, str ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1941 CHECK( 1, (str[0] != '\0') ? 1 : 0 );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1942
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1943 /* fd_cnx_recv_setaltfifo */
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1181
diff changeset
1944 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
767
c47c16436f71 Added a limit on fifo queues to avoid memory exaustion when messages are received faster than handled
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
1945 CHECK( 0, fd_fifo_new(&myfifo, 0) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1946 CHECK( 0, fd_cnx_recv_setaltfifo(server_side, myfifo) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1947 CHECK( 0, clock_gettime(CLOCK_REALTIME, &now) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1948 do {
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1949 CHECK( 0, fd_event_timedget(myfifo, &now, ETIMEDOUT, &ev_code, NULL, (void *)&rcv_buf) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1950 free(rcv_buf);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1951 } while (ev_code != FDEVP_CNX_MSG_RECV);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1952
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1953 /* Now close the connection */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1954 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) );
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1955 fd_cnx_destroy(server_side);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1956 CHECK( 0, pthread_join(thr, NULL) );
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1957
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1958 fd_event_destroy(&myfifo, free);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1959
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1960 /* Free the credentials */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1961 gnutls_certificate_free_keys(hf.creds);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1962 gnutls_certificate_free_cas(hf.creds);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1963 gnutls_certificate_free_credentials(hf.creds);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1964 }
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1965 #endif /* DISABLE_SCTP */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1966
393
6d9ee5ab79e5 Added test case for ticket #6
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
1967
32
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1968 /* Destroy the servers */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1969 {
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1970 fd_cnx_destroy(listener);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1971 #ifndef DISABLE_SCTP
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1972 fd_cnx_destroy(listener_sctp);
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1973 #endif /* DISABLE_SCTP */
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1974 }
a5b507479a09 Tested remaining cnxctx functions
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 31
diff changeset
1975
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1976 /* Check that connection attempt fails then */
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1977 {
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1978 struct connect_flags cf;
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1979
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1980 memset(&cf, 0, sizeof(cf));
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1981 cf.proto = IPPROTO_TCP;
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1982 cf.expect_failure = 1;
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1983
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1984 /* Start the client thread, that should fail */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1985 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1986 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1987 CHECK( 0, client_side ? 1 : 0 );
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1988 }
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1989
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1990 #ifndef DISABLE_SCTP
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1991 {
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1992 struct connect_flags cf;
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1993
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1994 memset(&cf, 0, sizeof(cf));
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1995 cf.proto = IPPROTO_SCTP;
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1996 cf.expect_failure = 1;
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1997
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
1998 /* Start the client thread, that should fail */
729
5d8ac5da7092 Fixed timeout handling + minor fixes
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
1999 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) );
38
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
2000 CHECK( 0, pthread_join( thr, (void *)&client_side ) );
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
2001 CHECK( 0, client_side ? 1 : 0 );
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
2002 }
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
2003 #endif /* DISABLE_SCTP */
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
2004
68c1890f7049 Fixed a small bug in SCTP close
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 32
diff changeset
2005
29
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2006 /* That's all for the tests yet */
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2007 PASSTEST();
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2008 }
5ba91682f0bc Added a test for cnxctx (tbc) and fixed some bugs
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2009
"Welcome to our mercurial repository"