remove duplicate project1
parent
d3cb543538
commit
5f25f98418
|
@ -1,87 +0,0 @@
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEnjCCA4agAwIBAgIJAOnQp195JfQ8MA0GCSqGSIb3DQEBBQUAMIGQMQswCQYD
|
|
||||||
VQQGEwJVUzEQMA4GA1UECBMHTW9udGFuYTEQMA4GA1UEBxMHQm96ZW1hbjERMA8G
|
|
||||||
A1UEChMIU2F3dG9vdGgxEzARBgNVBAsTCkNvbnN1bHRpbmcxFjAUBgNVBAMTDXd3
|
|
||||||
dy55YXNzbC5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMB4XDTEx
|
|
||||||
MTAyNDE4MTgxNVoXDTE0MDcyMDE4MTgxNVowgZAxCzAJBgNVBAYTAlVTMRAwDgYD
|
|
||||||
VQQIEwdNb250YW5hMRAwDgYDVQQHEwdCb3plbWFuMREwDwYDVQQKEwhTYXd0b290
|
|
||||||
aDETMBEGA1UECxMKQ29uc3VsdGluZzEWMBQGA1UEAxMNd3d3Lnlhc3NsLmNvbTEd
|
|
||||||
MBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb20wggEiMA0GCSqGSIb3DQEBAQUA
|
|
||||||
A4IBDwAwggEKAoIBAQC/DMotFLIehEJbzTgfSvJNdRDxtjWf38p9A5jTrN4DZu4q
|
|
||||||
8diwfW4HVAsQmCFNgMsSIOfMT95FfclydzLqypC7aVIQAy+o85XF8YtiVhvvZ2+k
|
|
||||||
EEGVrQqb46XAsNJwdlAwW6joCCx87aeieo04KRysx+3yfJWwlYJ9SVw4zXcl772A
|
|
||||||
dVOUPD3KY1ufFbXTHRMvGdE823Y6zLh9yeXC19pAb9gh3HMbQi1TnP4a/H2rejY/
|
|
||||||
mN6EfAVnzmoUOIep8Yy1aMtof3EgK/WgY/VWL6Mm0rdvsVoX1ziZCP6TWG/+wxNJ
|
|
||||||
CBYLp01nAFIxZyNOmO1RRR25BNkL7Ngos0u97TZ5AgMBAAGjgfgwgfUwHQYDVR0O
|
|
||||||
BBYEFCeOZxF0wyYdP+0zY7Ok2B0w5ejVMIHFBgNVHSMEgb0wgbqAFCeOZxF0wyYd
|
|
||||||
P+0zY7Ok2B0w5ejVoYGWpIGTMIGQMQswCQYDVQQGEwJVUzEQMA4GA1UECBMHTW9u
|
|
||||||
dGFuYTEQMA4GA1UEBxMHQm96ZW1hbjERMA8GA1UEChMIU2F3dG9vdGgxEzARBgNV
|
|
||||||
BAsTCkNvbnN1bHRpbmcxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkqhkiG
|
|
||||||
9w0BCQEWDmluZm9AeWFzc2wuY29tggkA6dCnX3kl9DwwDAYDVR0TBAUwAwEB/zAN
|
|
||||||
BgkqhkiG9w0BAQUFAAOCAQEAX4YU9FGLvKVOMNperJr4bNkmS5P54xyJb57us513
|
|
||||||
PokgdqPm6IYVIdviM7I01dCf88Gkh5Jc+dH/MC+OA7yzPAwyo5BfGpAer53zntcH
|
|
||||||
Aql9J2ZjL68Y16wYmIyDjzjzC6w2EHX7ynYTUFsCj3O/46Dug1IlVM4mzpy9L3mr
|
|
||||||
G2C4kvEDwPw7CNnArdVyCCWAYS3cn6eDYgdH4AdMSwcwBKmHHFV/BxLQy0Jdy89m
|
|
||||||
ARoX7vkPYLfbb2jlTkFibtNvYE9LJ97PGAfxE13LP6klRNpSXMgE4VYS9SqQTtHi
|
|
||||||
rwG1I6HsMdp7Y2nEuPPnzqE9wNtt87LZRsifw7hwWh9/yg==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
Certificate:
|
|
||||||
Data:
|
|
||||||
Version: 3 (0x2)
|
|
||||||
Serial Number:
|
|
||||||
e9:d0:a7:5f:79:25:f4:3c
|
|
||||||
Signature Algorithm: sha1WithRSAEncryption
|
|
||||||
Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
Validity
|
|
||||||
Not Before: Oct 24 18:18:15 2011 GMT
|
|
||||||
Not After : Jul 20 18:18:15 2014 GMT
|
|
||||||
Subject: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
Subject Public Key Info:
|
|
||||||
Public Key Algorithm: rsaEncryption
|
|
||||||
RSA Public Key: (2048 bit)
|
|
||||||
Modulus (2048 bit):
|
|
||||||
00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a:
|
|
||||||
f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac:
|
|
||||||
de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98:
|
|
||||||
21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77:
|
|
||||||
32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1:
|
|
||||||
8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3:
|
|
||||||
a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed:
|
|
||||||
a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95:
|
|
||||||
82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c:
|
|
||||||
3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db:
|
|
||||||
76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc:
|
|
||||||
73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98:
|
|
||||||
de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68:
|
|
||||||
cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2:
|
|
||||||
b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3:
|
|
||||||
13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98:
|
|
||||||
ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed:
|
|
||||||
36:79
|
|
||||||
Exponent: 65537 (0x10001)
|
|
||||||
X509v3 extensions:
|
|
||||||
X509v3 Subject Key Identifier:
|
|
||||||
27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
|
||||||
X509v3 Authority Key Identifier:
|
|
||||||
keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
|
||||||
DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
serial:E9:D0:A7:5F:79:25:F4:3C
|
|
||||||
|
|
||||||
X509v3 Basic Constraints:
|
|
||||||
CA:TRUE
|
|
||||||
Signature Algorithm: sha1WithRSAEncryption
|
|
||||||
5f:86:14:f4:51:8b:bc:a5:4e:30:da:5e:ac:9a:f8:6c:d9:26:
|
|
||||||
4b:93:f9:e3:1c:89:6f:9e:ee:b3:9d:77:3e:89:20:76:a3:e6:
|
|
||||||
e8:86:15:21:db:e2:33:b2:34:d5:d0:9f:f3:c1:a4:87:92:5c:
|
|
||||||
f9:d1:ff:30:2f:8e:03:bc:b3:3c:0c:32:a3:90:5f:1a:90:1e:
|
|
||||||
af:9d:f3:9e:d7:07:02:a9:7d:27:66:63:2f:af:18:d7:ac:18:
|
|
||||||
98:8c:83:8f:38:f3:0b:ac:36:10:75:fb:ca:76:13:50:5b:02:
|
|
||||||
8f:73:bf:e3:a0:ee:83:52:25:54:ce:26:ce:9c:bd:2f:79:ab:
|
|
||||||
1b:60:b8:92:f1:03:c0:fc:3b:08:d9:c0:ad:d5:72:08:25:80:
|
|
||||||
61:2d:dc:9f:a7:83:62:07:47:e0:07:4c:4b:07:30:04:a9:87:
|
|
||||||
1c:55:7f:07:12:d0:cb:42:5d:cb:cf:66:01:1a:17:ee:f9:0f:
|
|
||||||
60:b7:db:6f:68:e5:4e:41:62:6e:d3:6f:60:4f:4b:27:de:cf:
|
|
||||||
18:07:f1:13:5d:cb:3f:a9:25:44:da:52:5c:c8:04:e1:56:12:
|
|
||||||
f5:2a:90:4e:d1:e2:af:01:b5:23:a1:ec:31:da:7b:63:69:c4:
|
|
||||||
b8:f3:e7:ce:a1:3d:c0:db:6d:f3:b2:d9:46:c8:9f:c3:b8:70:
|
|
||||||
5a:1f:7f:ca
|
|
|
@ -1,158 +0,0 @@
|
||||||
Certificate:
|
|
||||||
Data:
|
|
||||||
Version: 1 (0x0)
|
|
||||||
Serial Number: 2 (0x2)
|
|
||||||
Signature Algorithm: sha1WithRSAEncryption
|
|
||||||
Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
Validity
|
|
||||||
Not Before: Oct 24 18:27:13 2011 GMT
|
|
||||||
Not After : Jul 20 18:27:13 2014 GMT
|
|
||||||
Subject: C=US, ST=Montana, L=Bozeman, O=yaSSL, OU=Support, CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
Subject Public Key Info:
|
|
||||||
Public Key Algorithm: rsaEncryption
|
|
||||||
RSA Public Key: (2048 bit)
|
|
||||||
Modulus (2048 bit):
|
|
||||||
00:c0:95:08:e1:57:41:f2:71:6d:b7:d2:45:41:27:
|
|
||||||
01:65:c6:45:ae:f2:bc:24:30:b8:95:ce:2f:4e:d6:
|
|
||||||
f6:1c:88:bc:7c:9f:fb:a8:67:7f:fe:5c:9c:51:75:
|
|
||||||
f7:8a:ca:07:e7:35:2f:8f:e1:bd:7b:c0:2f:7c:ab:
|
|
||||||
64:a8:17:fc:ca:5d:7b:ba:e0:21:e5:72:2e:6f:2e:
|
|
||||||
86:d8:95:73:da:ac:1b:53:b9:5f:3f:d7:19:0d:25:
|
|
||||||
4f:e1:63:63:51:8b:0b:64:3f:ad:43:b8:a5:1c:5c:
|
|
||||||
34:b3:ae:00:a0:63:c5:f6:7f:0b:59:68:78:73:a6:
|
|
||||||
8c:18:a9:02:6d:af:c3:19:01:2e:b8:10:e3:c6:cc:
|
|
||||||
40:b4:69:a3:46:33:69:87:6e:c4:bb:17:a6:f3:e8:
|
|
||||||
dd:ad:73:bc:7b:2f:21:b5:fd:66:51:0c:bd:54:b3:
|
|
||||||
e1:6d:5f:1c:bc:23:73:d1:09:03:89:14:d2:10:b9:
|
|
||||||
64:c3:2a:d0:a1:96:4a:bc:e1:d4:1a:5b:c7:a0:c0:
|
|
||||||
c1:63:78:0f:44:37:30:32:96:80:32:23:95:a1:77:
|
|
||||||
ba:13:d2:97:73:e2:5d:25:c9:6a:0d:c3:39:60:a4:
|
|
||||||
b4:b0:69:42:42:09:e9:d8:08:bc:33:20:b3:58:22:
|
|
||||||
a7:aa:eb:c4:e1:e6:61:83:c5:d2:96:df:d9:d0:4f:
|
|
||||||
ad:d7
|
|
||||||
Exponent: 65537 (0x10001)
|
|
||||||
Signature Algorithm: sha1WithRSAEncryption
|
|
||||||
71:4e:d3:62:df:cc:4c:f7:cd:b7:6e:52:0b:6c:6e:e0:bd:c2:
|
|
||||||
2d:07:d7:c0:b0:6e:43:1e:35:bc:30:01:50:f0:ff:99:23:6c:
|
|
||||||
18:1a:41:b6:11:d6:d4:19:61:fd:e4:77:97:1c:39:e1:57:ab:
|
|
||||||
c5:15:63:77:11:36:5e:74:e2:24:0b:1f:41:78:ad:b7:81:e7:
|
|
||||||
b4:40:66:80:f0:4b:91:a0:6d:a8:6e:3d:53:d9:8b:ce:2a:e1:
|
|
||||||
0b:45:65:87:a1:96:ae:ee:3e:88:d5:12:1f:78:17:ae:2c:c5:
|
|
||||||
73:44:d8:dc:f4:af:d8:cc:ae:4c:e1:0c:be:55:a4:99:f7:6e:
|
|
||||||
96:c0:c8:45:87:bf:dc:51:57:ff:9e:73:37:6a:18:9c:c3:f9:
|
|
||||||
22:7a:f4:b0:52:bd:fc:21:30:f8:c5:ff:1e:87:7d:ad:a2:5a:
|
|
||||||
35:f5:22:a8:b4:0a:76:38:e6:76:b0:98:af:1b:ec:8a:0a:43:
|
|
||||||
74:d2:85:34:37:84:07:e1:f6:23:b2:29:de:a6:b6:b7:4c:57:
|
|
||||||
7e:96:06:cb:a9:16:25:29:3a:03:2d:55:7d:a6:8c:a4:f7:9e:
|
|
||||||
81:c9:95:b6:7c:c1:4a:ce:94:66:0c:ca:88:eb:d2:09:f5:5b:
|
|
||||||
19:58:82:df:27:fd:67:95:78:b7:02:06:d5:a7:61:bd:ef:3a:
|
|
||||||
fc:b2:61:cd
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDkDCCAngCAQIwDQYJKoZIhvcNAQEFBQAwgZAxCzAJBgNVBAYTAlVTMRAwDgYD
|
|
||||||
VQQIEwdNb250YW5hMRAwDgYDVQQHEwdCb3plbWFuMREwDwYDVQQKEwhTYXd0b290
|
|
||||||
aDETMBEGA1UECxMKQ29uc3VsdGluZzEWMBQGA1UEAxMNd3d3Lnlhc3NsLmNvbTEd
|
|
||||||
MBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb20wHhcNMTExMDI0MTgyNzEzWhcN
|
|
||||||
MTQwNzIwMTgyNzEzWjCBijELMAkGA1UEBhMCVVMxEDAOBgNVBAgTB01vbnRhbmEx
|
|
||||||
EDAOBgNVBAcTB0JvemVtYW4xDjAMBgNVBAoTBXlhU1NMMRAwDgYDVQQLEwdTdXBw
|
|
||||||
b3J0MRYwFAYDVQQDEw13d3cueWFzc2wuY29tMR0wGwYJKoZIhvcNAQkBFg5pbmZv
|
|
||||||
QHlhc3NsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMCVCOFX
|
|
||||||
QfJxbbfSRUEnAWXGRa7yvCQwuJXOL07W9hyIvHyf+6hnf/5cnFF194rKB+c1L4/h
|
|
||||||
vXvAL3yrZKgX/Mpde7rgIeVyLm8uhtiVc9qsG1O5Xz/XGQ0lT+FjY1GLC2Q/rUO4
|
|
||||||
pRxcNLOuAKBjxfZ/C1loeHOmjBipAm2vwxkBLrgQ48bMQLRpo0YzaYduxLsXpvPo
|
|
||||||
3a1zvHsvIbX9ZlEMvVSz4W1fHLwjc9EJA4kU0hC5ZMMq0KGWSrzh1Bpbx6DAwWN4
|
|
||||||
D0Q3MDKWgDIjlaF3uhPSl3PiXSXJag3DOWCktLBpQkIJ6dgIvDMgs1gip6rrxOHm
|
|
||||||
YYPF0pbf2dBPrdcCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAcU7TYt/MTPfNt25S
|
|
||||||
C2xu4L3CLQfXwLBuQx41vDABUPD/mSNsGBpBthHW1Blh/eR3lxw54VerxRVjdxE2
|
|
||||||
XnTiJAsfQXitt4HntEBmgPBLkaBtqG49U9mLzirhC0Vlh6GWru4+iNUSH3gXrizF
|
|
||||||
c0TY3PSv2MyuTOEMvlWkmfdulsDIRYe/3FFX/55zN2oYnMP5Inr0sFK9/CEw+MX/
|
|
||||||
Hod9raJaNfUiqLQKdjjmdrCYrxvsigpDdNKFNDeEB+H2I7Ip3qa2t0xXfpYGy6kW
|
|
||||||
JSk6Ay1VfaaMpPeegcmVtnzBSs6UZgzKiOvSCfVbGViC3yf9Z5V4twIG1adhve86
|
|
||||||
/LJhzQ==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
Certificate:
|
|
||||||
Data:
|
|
||||||
Version: 3 (0x2)
|
|
||||||
Serial Number:
|
|
||||||
e9:d0:a7:5f:79:25:f4:3c
|
|
||||||
Signature Algorithm: sha1WithRSAEncryption
|
|
||||||
Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
Validity
|
|
||||||
Not Before: Oct 24 18:18:15 2011 GMT
|
|
||||||
Not After : Jul 20 18:18:15 2014 GMT
|
|
||||||
Subject: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
Subject Public Key Info:
|
|
||||||
Public Key Algorithm: rsaEncryption
|
|
||||||
RSA Public Key: (2048 bit)
|
|
||||||
Modulus (2048 bit):
|
|
||||||
00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a:
|
|
||||||
f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac:
|
|
||||||
de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98:
|
|
||||||
21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77:
|
|
||||||
32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1:
|
|
||||||
8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3:
|
|
||||||
a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed:
|
|
||||||
a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95:
|
|
||||||
82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c:
|
|
||||||
3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db:
|
|
||||||
76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc:
|
|
||||||
73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98:
|
|
||||||
de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68:
|
|
||||||
cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2:
|
|
||||||
b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3:
|
|
||||||
13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98:
|
|
||||||
ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed:
|
|
||||||
36:79
|
|
||||||
Exponent: 65537 (0x10001)
|
|
||||||
X509v3 extensions:
|
|
||||||
X509v3 Subject Key Identifier:
|
|
||||||
27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
|
||||||
X509v3 Authority Key Identifier:
|
|
||||||
keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5
|
|
||||||
DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.yassl.com/emailAddress=info@yassl.com
|
|
||||||
serial:E9:D0:A7:5F:79:25:F4:3C
|
|
||||||
|
|
||||||
X509v3 Basic Constraints:
|
|
||||||
CA:TRUE
|
|
||||||
Signature Algorithm: sha1WithRSAEncryption
|
|
||||||
5f:86:14:f4:51:8b:bc:a5:4e:30:da:5e:ac:9a:f8:6c:d9:26:
|
|
||||||
4b:93:f9:e3:1c:89:6f:9e:ee:b3:9d:77:3e:89:20:76:a3:e6:
|
|
||||||
e8:86:15:21:db:e2:33:b2:34:d5:d0:9f:f3:c1:a4:87:92:5c:
|
|
||||||
f9:d1:ff:30:2f:8e:03:bc:b3:3c:0c:32:a3:90:5f:1a:90:1e:
|
|
||||||
af:9d:f3:9e:d7:07:02:a9:7d:27:66:63:2f:af:18:d7:ac:18:
|
|
||||||
98:8c:83:8f:38:f3:0b:ac:36:10:75:fb:ca:76:13:50:5b:02:
|
|
||||||
8f:73:bf:e3:a0:ee:83:52:25:54:ce:26:ce:9c:bd:2f:79:ab:
|
|
||||||
1b:60:b8:92:f1:03:c0:fc:3b:08:d9:c0:ad:d5:72:08:25:80:
|
|
||||||
61:2d:dc:9f:a7:83:62:07:47:e0:07:4c:4b:07:30:04:a9:87:
|
|
||||||
1c:55:7f:07:12:d0:cb:42:5d:cb:cf:66:01:1a:17:ee:f9:0f:
|
|
||||||
60:b7:db:6f:68:e5:4e:41:62:6e:d3:6f:60:4f:4b:27:de:cf:
|
|
||||||
18:07:f1:13:5d:cb:3f:a9:25:44:da:52:5c:c8:04:e1:56:12:
|
|
||||||
f5:2a:90:4e:d1:e2:af:01:b5:23:a1:ec:31:da:7b:63:69:c4:
|
|
||||||
b8:f3:e7:ce:a1:3d:c0:db:6d:f3:b2:d9:46:c8:9f:c3:b8:70:
|
|
||||||
5a:1f:7f:ca
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEnjCCA4agAwIBAgIJAOnQp195JfQ8MA0GCSqGSIb3DQEBBQUAMIGQMQswCQYD
|
|
||||||
VQQGEwJVUzEQMA4GA1UECBMHTW9udGFuYTEQMA4GA1UEBxMHQm96ZW1hbjERMA8G
|
|
||||||
A1UEChMIU2F3dG9vdGgxEzARBgNVBAsTCkNvbnN1bHRpbmcxFjAUBgNVBAMTDXd3
|
|
||||||
dy55YXNzbC5jb20xHTAbBgkqhkiG9w0BCQEWDmluZm9AeWFzc2wuY29tMB4XDTEx
|
|
||||||
MTAyNDE4MTgxNVoXDTE0MDcyMDE4MTgxNVowgZAxCzAJBgNVBAYTAlVTMRAwDgYD
|
|
||||||
VQQIEwdNb250YW5hMRAwDgYDVQQHEwdCb3plbWFuMREwDwYDVQQKEwhTYXd0b290
|
|
||||||
aDETMBEGA1UECxMKQ29uc3VsdGluZzEWMBQGA1UEAxMNd3d3Lnlhc3NsLmNvbTEd
|
|
||||||
MBsGCSqGSIb3DQEJARYOaW5mb0B5YXNzbC5jb20wggEiMA0GCSqGSIb3DQEBAQUA
|
|
||||||
A4IBDwAwggEKAoIBAQC/DMotFLIehEJbzTgfSvJNdRDxtjWf38p9A5jTrN4DZu4q
|
|
||||||
8diwfW4HVAsQmCFNgMsSIOfMT95FfclydzLqypC7aVIQAy+o85XF8YtiVhvvZ2+k
|
|
||||||
EEGVrQqb46XAsNJwdlAwW6joCCx87aeieo04KRysx+3yfJWwlYJ9SVw4zXcl772A
|
|
||||||
dVOUPD3KY1ufFbXTHRMvGdE823Y6zLh9yeXC19pAb9gh3HMbQi1TnP4a/H2rejY/
|
|
||||||
mN6EfAVnzmoUOIep8Yy1aMtof3EgK/WgY/VWL6Mm0rdvsVoX1ziZCP6TWG/+wxNJ
|
|
||||||
CBYLp01nAFIxZyNOmO1RRR25BNkL7Ngos0u97TZ5AgMBAAGjgfgwgfUwHQYDVR0O
|
|
||||||
BBYEFCeOZxF0wyYdP+0zY7Ok2B0w5ejVMIHFBgNVHSMEgb0wgbqAFCeOZxF0wyYd
|
|
||||||
P+0zY7Ok2B0w5ejVoYGWpIGTMIGQMQswCQYDVQQGEwJVUzEQMA4GA1UECBMHTW9u
|
|
||||||
dGFuYTEQMA4GA1UEBxMHQm96ZW1hbjERMA8GA1UEChMIU2F3dG9vdGgxEzARBgNV
|
|
||||||
BAsTCkNvbnN1bHRpbmcxFjAUBgNVBAMTDXd3dy55YXNzbC5jb20xHTAbBgkqhkiG
|
|
||||||
9w0BCQEWDmluZm9AeWFzc2wuY29tggkA6dCnX3kl9DwwDAYDVR0TBAUwAwEB/zAN
|
|
||||||
BgkqhkiG9w0BAQUFAAOCAQEAX4YU9FGLvKVOMNperJr4bNkmS5P54xyJb57us513
|
|
||||||
PokgdqPm6IYVIdviM7I01dCf88Gkh5Jc+dH/MC+OA7yzPAwyo5BfGpAer53zntcH
|
|
||||||
Aql9J2ZjL68Y16wYmIyDjzjzC6w2EHX7ynYTUFsCj3O/46Dug1IlVM4mzpy9L3mr
|
|
||||||
G2C4kvEDwPw7CNnArdVyCCWAYS3cn6eDYgdH4AdMSwcwBKmHHFV/BxLQy0Jdy89m
|
|
||||||
ARoX7vkPYLfbb2jlTkFibtNvYE9LJ97PGAfxE13LP6klRNpSXMgE4VYS9SqQTtHi
|
|
||||||
rwG1I6HsMdp7Y2nEuPPnzqE9wNtt87LZRsifw7hwWh9/yg==
|
|
||||||
-----END CERTIFICATE-----
|
|
|
@ -1,27 +0,0 @@
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpQIBAAKCAQEAwJUI4VdB8nFtt9JFQScBZcZFrvK8JDC4lc4vTtb2HIi8fJ/7
|
|
||||||
qGd//lycUXX3isoH5zUvj+G9e8AvfKtkqBf8yl17uuAh5XIuby6G2JVz2qwbU7lf
|
|
||||||
P9cZDSVP4WNjUYsLZD+tQ7ilHFw0s64AoGPF9n8LWWh4c6aMGKkCba/DGQEuuBDj
|
|
||||||
xsxAtGmjRjNph27Euxem8+jdrXO8ey8htf1mUQy9VLPhbV8cvCNz0QkDiRTSELlk
|
|
||||||
wyrQoZZKvOHUGlvHoMDBY3gPRDcwMpaAMiOVoXe6E9KXc+JdJclqDcM5YKS0sGlC
|
|
||||||
Qgnp2Ai8MyCzWCKnquvE4eZhg8XSlt/Z0E+t1wIDAQABAoIBAQCa0DQPUmIFUAHv
|
|
||||||
n+1kbsLE2hryhNeSEEiSxOlq64t1bMZ5OPLJckqGZFSVd8vDmp231B2kAMieTuTd
|
|
||||||
x7pnFsF0vKnWlI8rMBr77d8hBSPZSjm9mGtlmrjcxH3upkMVLj2+HSJgKnMw1T7Y
|
|
||||||
oqyGQy7E9WReP4l1DxHYUSVOn9iqo85gs+KK2X4b8GTKmlsFC1uqy+XjP24yIgXz
|
|
||||||
0PrvdFKB4l90073/MYNFdfpjepcu1rYZxpIm5CgGUFAOeC6peA0Ul7QS2DFAq6EB
|
|
||||||
QcIw+AdfFuRhd9Jg8p+N6PS662PeKpeB70xs5lU0USsoNPRTHMRYCj+7r7X3SoVD
|
|
||||||
LTzxWFiBAoGBAPIsVHY5I2PJEDK3k62vvhl1loFk5rW4iUJB0W3QHBv4G6xpyzY8
|
|
||||||
ZH3c9Bm4w2CxV0hfUk9ZOlV/MsAZQ1A/rs5vF/MOn0DKTq0VO8l56cBZOHNwnAp8
|
|
||||||
yTpIMqfYSXUKhcLC/RVz2pkJKmmanwpxv7AEpox6Wm9IWlQ7xrFTF9/nAoGBAMuT
|
|
||||||
3ncVXbdcXHzYkKmYLdZpDmOzo9ymzItqpKISjI57SCyySzfcBhh96v52odSh6T8N
|
|
||||||
zRtfr1+elltbD6F8r7ObkNtXczrtsCNErkFPHwdCEyNMy/r0FKTV9542fFufqDzB
|
|
||||||
hV900jkt/9CE3/uzIHoumxeu5roLrl9TpFLtG8SRAoGBAOyY2rvV/vlSSn0CVUlv
|
|
||||||
VW5SL4SjK7OGYrNU0mNS2uOIdqDvixWl0xgUcndex6MEH54ZYrUbG57D8rUy+UzB
|
|
||||||
qusMJn3UX0pRXKRFBnBEp1bA1CIUdp7YY1CJkNPiv4GVkjFBhzkaQwsYpVMfORpf
|
|
||||||
H0O8h2rfbtMiAP4imHBOGhkpAoGBAIpBVihRnl/Ungs7mKNU8mxW1KrpaTOFJAza
|
|
||||||
1AwtxL9PAmk4fNTm3Ezt1xYRwz4A58MmwFEC3rt1nG9WnHrzju/PisUr0toGakTJ
|
|
||||||
c/5umYf4W77xfOZltU9s8MnF/xbKixsX4lg9ojerAby/QM5TjI7t7+5ZneBj5nxe
|
|
||||||
9Y5L8TvBAoGATUX5QIzFW/QqGoq08hysa+kMVja3TnKW1eWK0uL/8fEYEz2GCbjY
|
|
||||||
dqfJHHFSlDBD4PF4dP1hG0wJzOZoKnGtHN9DvFbbpaS+NXCkXs9P/ABVmTo9I89n
|
|
||||||
WvUi+LUp0EQR6zUuRr79jhiyX6i/GTKh9dwD5nyaHwx8qbAOITc78bA=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
|
@ -1,21 +0,0 @@
|
||||||
DEPS = ../include/unp.h
|
|
||||||
CC=gcc
|
|
||||||
CFLAGS=-Wall -I ../include -DCYASSL_DTLS
|
|
||||||
OBJ = echoserver.o
|
|
||||||
|
|
||||||
#if you are on a sunOS (System V) machine, you'll need to uncomment
|
|
||||||
#the next line.
|
|
||||||
|
|
||||||
#LIBS=-lsocket
|
|
||||||
%.o: %.c $(DEPS)
|
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
|
||||||
all: server
|
|
||||||
|
|
||||||
server: server-dtls.c
|
|
||||||
$(CC) -Wall -DCYASSL_DTLS -o server server-dtls.c -I ../include -lcyassl
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f *.o server
|
|
|
@ -1,220 +0,0 @@
|
||||||
/* server-dtls.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
|
||||||
*
|
|
||||||
* This file is part of CyaSSL.
|
|
||||||
*
|
|
||||||
* CyaSSL is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* CyaSSL is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
||||||
* USA
|
|
||||||
*=============================================================================
|
|
||||||
*
|
|
||||||
* Bare-bones example of a DTLS server for instructional/learning purposes.
|
|
||||||
* Utilizes DTLS 1.2.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h> /* standard in/out procedures */
|
|
||||||
#include <stdlib.h> /* defines system calls */
|
|
||||||
#include <string.h> /* necessary for memset */
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <sys/socket.h> /* used for all socket calls */
|
|
||||||
#include <netinet/in.h> /* used for sockaddr_in */
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <cyassl/ssl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define SERV_PORT 11111 /* define our server port number */
|
|
||||||
#define MSGLEN 4096
|
|
||||||
|
|
||||||
static int cleanup; /* To handle shutdown */
|
|
||||||
struct sockaddr_in servAddr; /* our server's address */
|
|
||||||
struct sockaddr_in cliaddr; /* the client's address */
|
|
||||||
|
|
||||||
int AwaitDGram(CYASSL_CTX* ctx); /* Separate out Handling Datagrams */
|
|
||||||
void CleanUp();
|
|
||||||
|
|
||||||
int AwaitDGram(CYASSL_CTX* ctx)
|
|
||||||
{
|
|
||||||
int on = 1;
|
|
||||||
int res = 1;
|
|
||||||
int connfd = 0;
|
|
||||||
int recvLen = 0; /* length of message */
|
|
||||||
int listenfd = 0; /* Initialize our socket */
|
|
||||||
CYASSL* ssl = NULL;
|
|
||||||
socklen_t cliLen;
|
|
||||||
socklen_t len = sizeof(on);
|
|
||||||
unsigned char b[MSGLEN]; /* watch for incoming messages */
|
|
||||||
char buff[MSGLEN]; /* the incoming message */
|
|
||||||
char ack[] = "I hear you fashizzle!\n";
|
|
||||||
|
|
||||||
while (cleanup != 1) {
|
|
||||||
/* Create a UDP/IP socket */
|
|
||||||
if ((listenfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
|
|
||||||
printf("Cannot create socket.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
}
|
|
||||||
printf("Socket all/ocated\n");
|
|
||||||
|
|
||||||
/* clear servAddr each loop */
|
|
||||||
memset((char *)&servAddr, 0, sizeof(servAddr));
|
|
||||||
|
|
||||||
/* host-to-network-long conversion (htonl) */
|
|
||||||
/* host-to-network-short conversion (htons) */
|
|
||||||
servAddr.sin_family = AF_INET;
|
|
||||||
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
servAddr.sin_port = htons(SERV_PORT);
|
|
||||||
|
|
||||||
/* Eliminate socket already in use error */
|
|
||||||
res = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
|
||||||
if (res < 0) {
|
|
||||||
printf("Setsockopt SO_REUSEADDR failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Bind Socket*/
|
|
||||||
if (bind(listenfd,
|
|
||||||
(struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) {
|
|
||||||
printf("Bind failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Awaiting client connection on port %d\n", SERV_PORT);
|
|
||||||
|
|
||||||
cliLen = sizeof(cliaddr);
|
|
||||||
connfd = (int)recvfrom(listenfd, (char *)&b, sizeof(b), MSG_PEEK,
|
|
||||||
(struct sockaddr*)&cliaddr, &cliLen);
|
|
||||||
|
|
||||||
if (connfd < 0) {
|
|
||||||
printf("No clients in que, enter idle state\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (connfd > 0) {
|
|
||||||
if (connect(listenfd, (const struct sockaddr *)&cliaddr,
|
|
||||||
sizeof(cliaddr)) != 0) {
|
|
||||||
printf("Udp connect failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("Recvfrom failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
printf("Connected!\n");
|
|
||||||
|
|
||||||
/* Create the CYASSL Object */
|
|
||||||
if ((ssl = CyaSSL_new(ctx)) == NULL) {
|
|
||||||
printf("CyaSSL_new error.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the session ssl to client connection port */
|
|
||||||
CyaSSL_set_fd(ssl, listenfd);
|
|
||||||
|
|
||||||
if (CyaSSL_accept(ssl) != SSL_SUCCESS) {
|
|
||||||
|
|
||||||
int e = CyaSSL_get_error(ssl, 0);
|
|
||||||
|
|
||||||
printf("error = %d, %s\n", e, CyaSSL_ERR_reason_error_string(e));
|
|
||||||
printf("SSL_accept failed.\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ((recvLen = CyaSSL_read(ssl, buff, sizeof(buff)-1)) > 0) {
|
|
||||||
printf("heard %d bytes\n", recvLen);
|
|
||||||
|
|
||||||
buff[recvLen] = 0;
|
|
||||||
printf("I heard this: \"%s\"\n", buff);
|
|
||||||
}
|
|
||||||
else if (recvLen < 0) {
|
|
||||||
int readErr = CyaSSL_get_error(ssl, 0);
|
|
||||||
if(readErr != SSL_ERROR_WANT_READ) {
|
|
||||||
printf("SSL_read failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CyaSSL_write(ssl, ack, sizeof(ack)) < 0) {
|
|
||||||
printf("CyaSSL_write fail.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("Sending reply.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("reply sent \"%s\"\n", ack);
|
|
||||||
|
|
||||||
CyaSSL_set_fd(ssl, 0);
|
|
||||||
CyaSSL_shutdown(ssl);
|
|
||||||
CyaSSL_free(ssl);
|
|
||||||
|
|
||||||
printf("Client left return to idle state\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
/* cont short for "continue?", Loc short for "location" */
|
|
||||||
int cont = 0;
|
|
||||||
char caCertLoc[] = "../certs/ca-cert.pem";
|
|
||||||
char servCertLoc[] = "../certs/server-cert.pem";
|
|
||||||
char servKeyLoc[] = "../certs/server-key.pem";
|
|
||||||
CYASSL_CTX* ctx;
|
|
||||||
|
|
||||||
/* "./config --enable-debug" and uncomment next line for debugging */
|
|
||||||
/* CyaSSL_Debugging_ON(); */
|
|
||||||
|
|
||||||
/* Initialize CyaSSL */
|
|
||||||
CyaSSL_Init();
|
|
||||||
|
|
||||||
/* Set ctx to DTLS 1.2 */
|
|
||||||
if ((ctx = CyaSSL_CTX_new(CyaDTLSv1_2_server_method())) == NULL) {
|
|
||||||
printf("CyaSSL_CTX_new error.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load CA certificates */
|
|
||||||
if (CyaSSL_CTX_load_verify_locations(ctx,caCertLoc,0) !=
|
|
||||||
SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", caCertLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load server certificates */
|
|
||||||
if (CyaSSL_CTX_use_certificate_file(ctx, servCertLoc, SSL_FILETYPE_PEM) !=
|
|
||||||
SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", servCertLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load server Keys */
|
|
||||||
if (CyaSSL_CTX_use_PrivateKey_file(ctx, servKeyLoc,
|
|
||||||
SSL_FILETYPE_PEM) != SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", servKeyLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cont = AwaitDGram(ctx);
|
|
||||||
|
|
||||||
if (cont == 1) {
|
|
||||||
CyaSSL_CTX_free(ctx);
|
|
||||||
CyaSSL_Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
DEPS = ../include/unp.h
|
|
||||||
CC=gcc
|
|
||||||
CFLAGS=-Wall -I ../include -DCYASSL_DTLS
|
|
||||||
OBJ = echoserver.o
|
|
||||||
|
|
||||||
#if you are on a sunOS (System V) machine, you'll need to uncomment
|
|
||||||
#the next line.
|
|
||||||
|
|
||||||
#LIBS=-lsocket
|
|
||||||
%.o: %.c $(DEPS)
|
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
|
||||||
all: server
|
|
||||||
|
|
||||||
server: server-dtls-threaded.c
|
|
||||||
$(CC) -Wall -DCYASSL_DTLS -o server server-dtls-threaded.c -lcyassl -lpthread
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f *.o server
|
|
|
@ -1,286 +0,0 @@
|
||||||
/* server-dtls-threaded.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
|
||||||
*
|
|
||||||
* This file is part of CyaSSL.
|
|
||||||
*
|
|
||||||
* CyaSSL is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* CyaSSL is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
||||||
* USA
|
|
||||||
*=============================================================================
|
|
||||||
*
|
|
||||||
* Bare-bones example of a DTLS server for instructional/learning purposes.
|
|
||||||
* Utilizes DTLS 1.2. and multi-threading
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h> /* standard in/out procedures */
|
|
||||||
#include <stdlib.h> /* defines system calls */
|
|
||||||
#include <string.h> /* necessary for memset */
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <sys/socket.h> /* used for all socket calls */
|
|
||||||
#include <netinet/in.h> /* used for sockaddr_in */
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <cyassl/ssl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#define SERV_PORT 11111 /* define our server port number */
|
|
||||||
#define MSGLEN 4096
|
|
||||||
|
|
||||||
CYASSL_CTX* ctx; /* must be global for ThreadControl */
|
|
||||||
static int cleanup; /* To handle shutdown */
|
|
||||||
struct sockaddr_in cliAddr; /* the client's address */
|
|
||||||
struct sockaddr_in servAddr; /* our server's address */
|
|
||||||
|
|
||||||
int AwaitDGram(CYASSL_CTX* ctx);
|
|
||||||
void* ThreadControl(void*);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int activefd;
|
|
||||||
int size;
|
|
||||||
unsigned char b[MSGLEN];
|
|
||||||
}threadArgs;
|
|
||||||
|
|
||||||
int AwaitDGram(CYASSL_CTX* ctx)
|
|
||||||
{
|
|
||||||
int on = 1;
|
|
||||||
int res = 1;
|
|
||||||
int bytesRcvd = 0;
|
|
||||||
int listenfd = 0; /* Initialize our socket */
|
|
||||||
socklen_t cliLen;
|
|
||||||
socklen_t len = sizeof(on);
|
|
||||||
unsigned char buf[MSGLEN]; /* watch for incoming messages */
|
|
||||||
|
|
||||||
/* Create a UDP/IP socket */
|
|
||||||
if ((listenfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
|
|
||||||
printf("Cannot create socket.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
}
|
|
||||||
printf("Socket allocated\n");
|
|
||||||
|
|
||||||
/* clear servAddr each loop */
|
|
||||||
memset((char *)&servAddr, 0, sizeof(servAddr));
|
|
||||||
|
|
||||||
/* host-to-network-long conversion (htonl) */
|
|
||||||
/* host-to-network-short conversion (htons) */
|
|
||||||
servAddr.sin_family = AF_INET;
|
|
||||||
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
servAddr.sin_port = htons(SERV_PORT);
|
|
||||||
|
|
||||||
/* Eliminate socket already in use error */
|
|
||||||
res = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
|
||||||
if (res < 0) {
|
|
||||||
printf("Setsockopt SO_REUSEADDR failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Bind Socket*/
|
|
||||||
if (bind(listenfd,
|
|
||||||
(struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) {
|
|
||||||
printf("Bind failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Awaiting client connection on port %d\n", SERV_PORT);
|
|
||||||
|
|
||||||
while (cleanup != 1) {
|
|
||||||
|
|
||||||
threadArgs* args;
|
|
||||||
args = (threadArgs *) malloc(sizeof(threadArgs));
|
|
||||||
|
|
||||||
cliLen = sizeof(cliAddr);
|
|
||||||
/* note argument 4 of recvfrom not MSG_PEEK as dtls will see
|
|
||||||
* handshake packets and think a message is arriving. Instead
|
|
||||||
* read any real message to struct and pass struct into thread
|
|
||||||
* for processing.
|
|
||||||
*/
|
|
||||||
bytesRcvd = (int)recvfrom(listenfd, (char *)buf, sizeof(buf), 0,
|
|
||||||
(struct sockaddr*)&cliAddr, &cliLen);
|
|
||||||
|
|
||||||
if (bytesRcvd < 0) {
|
|
||||||
printf("No clients in que, enter idle state\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (bytesRcvd > 0) {
|
|
||||||
|
|
||||||
memcpy(args->b, buf, sizeof(buf));
|
|
||||||
|
|
||||||
args->size = bytesRcvd;
|
|
||||||
|
|
||||||
if ((args->activefd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
|
|
||||||
printf("Cannot create socket.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = setsockopt(args->activefd, SOL_SOCKET, SO_REUSEADDR, &on,
|
|
||||||
len);
|
|
||||||
if (res < 0) {
|
|
||||||
printf("Setsockopt SO_REUSEADDR failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#ifdef SO_REUSEPORT
|
|
||||||
res = setsockopt(args->activefd, SOL_SOCKET, SO_REUSEPORT, &on, len);
|
|
||||||
if (res < 0) {
|
|
||||||
printf("Setsockopt SO_REUSEPORT failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (connect(args->activefd, (const struct sockaddr *)&cliAddr,
|
|
||||||
sizeof(cliAddr)) != 0) {
|
|
||||||
printf("Udp connect failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("Recvfrom failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
printf("Connected!\n");
|
|
||||||
|
|
||||||
pthread_t threadid;
|
|
||||||
printf("new id %d created.\n",(int) threadid);
|
|
||||||
/* SPIN A THREAD HERE TO HANDLE "buff" and "reply/ack" */
|
|
||||||
pthread_create(&threadid, NULL, ThreadControl, args);
|
|
||||||
printf("control passed to thread control.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ThreadControl(void* openSock)
|
|
||||||
{
|
|
||||||
pthread_detach(pthread_self());
|
|
||||||
|
|
||||||
threadArgs* args = (threadArgs*)openSock;
|
|
||||||
int recvLen = 0; /* length of message */
|
|
||||||
int activefd = args->activefd; /* the active descriptor */
|
|
||||||
int msgLen = args->size; /* the size of message */
|
|
||||||
unsigned char buff[msgLen]; /* the incoming message */
|
|
||||||
char ack[] = "I hear you fashizzle!\n";
|
|
||||||
CYASSL* ssl;
|
|
||||||
|
|
||||||
memcpy(buff, args->b, msgLen);
|
|
||||||
|
|
||||||
/* Create the CYASSL Object */
|
|
||||||
if ((ssl = CyaSSL_new(ctx)) == NULL) {
|
|
||||||
printf("CyaSSL_new error.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set the session ssl to client connection port */
|
|
||||||
CyaSSL_set_fd(ssl, activefd);
|
|
||||||
|
|
||||||
if (CyaSSL_accept(ssl) != SSL_SUCCESS) {
|
|
||||||
|
|
||||||
int e = CyaSSL_get_error(ssl, 0);
|
|
||||||
|
|
||||||
printf("error = %d, %s\n", e, CyaSSL_ERR_reason_error_string(e));
|
|
||||||
printf("SSL_accept failed.\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if ((recvLen = CyaSSL_read(ssl, buff, msgLen-1)) > 0) {
|
|
||||||
printf("heard %d bytes\n", recvLen);
|
|
||||||
|
|
||||||
buff[recvLen] = 0;
|
|
||||||
printf("I heard this: \"%s\"\n", buff);
|
|
||||||
}
|
|
||||||
else if (recvLen < 0) {
|
|
||||||
int readErr = CyaSSL_get_error(ssl, 0);
|
|
||||||
if(readErr != SSL_ERROR_WANT_READ) {
|
|
||||||
printf("SSL_read failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (CyaSSL_write(ssl, ack, sizeof(ack)) < 0) {
|
|
||||||
printf("CyaSSL_write fail.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("Sending reply.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("reply sent \"%s\"\n", ack);
|
|
||||||
|
|
||||||
|
|
||||||
CyaSSL_shutdown(ssl);
|
|
||||||
CyaSSL_free(ssl);
|
|
||||||
close(activefd);
|
|
||||||
free(openSock); /* valgrind friendly free */
|
|
||||||
|
|
||||||
printf("Client left return to idle state\n");
|
|
||||||
printf("Exiting thread.\n\n");
|
|
||||||
pthread_exit(openSock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
/* cont short for "continue?", Loc short for "location" */
|
|
||||||
int cont = 0;
|
|
||||||
char caCertLoc[] = "../certs/ca-cert.pem";
|
|
||||||
char servCertLoc[] = "../certs/server-cert.pem";
|
|
||||||
char servKeyLoc[] = "../certs/server-key.pem";
|
|
||||||
|
|
||||||
/* "./config --enable-debug" and uncomment next line for debugging */
|
|
||||||
/* CyaSSL_Debugging_ON(); */
|
|
||||||
|
|
||||||
/* Initialize CyaSSL */
|
|
||||||
CyaSSL_Init();
|
|
||||||
|
|
||||||
/* Set ctx to DTLS 1.2 */
|
|
||||||
if ((ctx = CyaSSL_CTX_new(CyaDTLSv1_2_server_method())) == NULL) {
|
|
||||||
printf("CyaSSL_CTX_new error.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load CA certificates */
|
|
||||||
if (CyaSSL_CTX_load_verify_locations(ctx,caCertLoc,0) !=
|
|
||||||
SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", caCertLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load server certificates */
|
|
||||||
if (CyaSSL_CTX_use_certificate_file(ctx, servCertLoc, SSL_FILETYPE_PEM) !=
|
|
||||||
SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", servCertLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load server Keys */
|
|
||||||
if (CyaSSL_CTX_use_PrivateKey_file(ctx, servKeyLoc,
|
|
||||||
SSL_FILETYPE_PEM) != SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", servKeyLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cont = AwaitDGram(ctx);
|
|
||||||
|
|
||||||
if (cont == 1) {
|
|
||||||
CyaSSL_CTX_free(ctx);
|
|
||||||
CyaSSL_Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
DEPS = ../include/unp.h
|
|
||||||
CC=gcc
|
|
||||||
CFLAGS=-Wall -I ../include -DCYASSL_DTLS
|
|
||||||
OBJ = echoserver.o
|
|
||||||
|
|
||||||
#if you are on a sunOS (System V) machine, you'll need to uncomment
|
|
||||||
#the next line.
|
|
||||||
|
|
||||||
#LIBS=-lsocket
|
|
||||||
%.o: %.c $(DEPS)
|
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
|
||||||
all: server
|
|
||||||
|
|
||||||
server: server-dtls-nonblocking.c
|
|
||||||
$(CC) -Wall -DCYASSL_DTLS -o server server-dtls-nonblocking.c -I ../include -lcyassl
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f *.o server
|
|
|
@ -1,345 +0,0 @@
|
||||||
/* server-dtls.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
|
||||||
*
|
|
||||||
* This file is part of CyaSSL.
|
|
||||||
*
|
|
||||||
* CyaSSL is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* CyaSSL is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
||||||
* USA
|
|
||||||
*=============================================================================
|
|
||||||
*
|
|
||||||
* Bare-bones example of a DTLS erver for instructional/learning purposes.
|
|
||||||
* Utilizes DTLS 1.2.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h> /* standard in/out procedures */
|
|
||||||
#include <stdlib.h> /* defines system calls */
|
|
||||||
#include <string.h> /* necessary for memset */
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <sys/socket.h> /* used for all socket calls */
|
|
||||||
#include <netinet/in.h> /* used for sockaddr_in */
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <cyassl/ssl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#define SERV_PORT 11111 /* define our server port number */
|
|
||||||
#define MSGLEN 4096
|
|
||||||
|
|
||||||
static int cleanup; /* To handle shutdown */
|
|
||||||
|
|
||||||
void dtls_set_nonblocking(int*); /* set the socket non-blocking */
|
|
||||||
int NonBlockingSSL_Accept(CYASSL*);/* non-blocking accept */
|
|
||||||
int AwaitDGram(CYASSL_CTX* ctx); /* Separate out Handling Datagrams */
|
|
||||||
int udp_read_connect(int); /* broken out to improve readability */
|
|
||||||
int dtls_select();
|
|
||||||
|
|
||||||
/* costumes for select_ret to wear */
|
|
||||||
enum {
|
|
||||||
TEST_SELECT_FAIL,
|
|
||||||
TEST_TIMEOUT,
|
|
||||||
TEST_RECV_READY,
|
|
||||||
TEST_ERROR_READY
|
|
||||||
};
|
|
||||||
|
|
||||||
int AwaitDGram(CYASSL_CTX* ctx)
|
|
||||||
{
|
|
||||||
int on = 1;
|
|
||||||
int res = 1;
|
|
||||||
int recvLen; /* length of string read */
|
|
||||||
int readWriteErr;
|
|
||||||
int listenfd = 0; /* Initialize our socket */
|
|
||||||
int clientfd = 0; /* client connection */
|
|
||||||
int len = sizeof(on);
|
|
||||||
int cont;
|
|
||||||
char buff[MSGLEN]; /* string read from client */
|
|
||||||
CYASSL* ssl = NULL; /* Initialize ssl object */
|
|
||||||
struct sockaddr_in servAddr; /* our server's address */
|
|
||||||
char ack[] = "I hear you fashizzle\n";
|
|
||||||
|
|
||||||
while (cleanup != 1) {
|
|
||||||
|
|
||||||
/* Create a UDP/IP socket */
|
|
||||||
if ((listenfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) {
|
|
||||||
printf("Cannot create socket.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Socket allocated\n");
|
|
||||||
memset((char *)&servAddr, 0, sizeof(servAddr));
|
|
||||||
|
|
||||||
/* host-to-network-long conversion (htonl) */
|
|
||||||
/* host-to-network-short conversion (htons) */
|
|
||||||
servAddr.sin_family = AF_INET;
|
|
||||||
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
servAddr.sin_port = htons(SERV_PORT);
|
|
||||||
|
|
||||||
/* Eliminate socket already in use error */
|
|
||||||
res = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
|
||||||
if (res < 0) {
|
|
||||||
printf("Setsockopt SO_REUSEADDR failed.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Bind Socket*/
|
|
||||||
if (bind(listenfd,
|
|
||||||
(struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) {
|
|
||||||
printf("Bind failed.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Awaiting client connection on port %d\n", SERV_PORT);
|
|
||||||
|
|
||||||
clientfd = udp_read_connect(listenfd);
|
|
||||||
dtls_set_nonblocking(&clientfd);
|
|
||||||
|
|
||||||
/* Create the CYASSL Object */
|
|
||||||
if (( ssl = CyaSSL_new(ctx)) == NULL) {
|
|
||||||
printf("CyaSSL_new error.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set clilen to |cliAddr| */
|
|
||||||
printf("Connected!\n");
|
|
||||||
|
|
||||||
/* set the/ session ssl to client connection port */
|
|
||||||
CyaSSL_set_fd(ssl, clientfd);
|
|
||||||
|
|
||||||
CyaSSL_set_using_nonblock(ssl, 1);
|
|
||||||
cont = NonBlockingSSL_Accept(ssl);
|
|
||||||
|
|
||||||
if (cont != 0) {
|
|
||||||
printf("NonBlockingSSL_Accept failed.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Begin: Reply to the client */
|
|
||||||
recvLen = CyaSSL_read(ssl, buff, sizeof(buff)-1);
|
|
||||||
|
|
||||||
/* Begin do-while read */
|
|
||||||
do {
|
|
||||||
if (cleanup == 1) {
|
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (recvLen < 0) {
|
|
||||||
readWriteErr = CyaSSL_get_error(ssl, 0);
|
|
||||||
if (readWriteErr != SSL_ERROR_WANT_READ) {
|
|
||||||
printf("Read Error, error was: %d.\n", readWriteErr);
|
|
||||||
cleanup = 1;
|
|
||||||
} else {
|
|
||||||
recvLen = CyaSSL_read(ssl, buff, sizeof(buff)-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} while (readWriteErr == SSL_ERROR_WANT_READ &&
|
|
||||||
recvLen < 0 &&
|
|
||||||
cleanup != 1);
|
|
||||||
/* End do-while read */
|
|
||||||
|
|
||||||
if (recvLen > 0) {
|
|
||||||
buff[recvLen] = 0;
|
|
||||||
printf("I heard this:\"%s\"\n", buff);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("Connection Timed Out.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Begin do-while write */
|
|
||||||
do {
|
|
||||||
if (cleanup == 1) {
|
|
||||||
memset(&buff, 0, sizeof(buff));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
readWriteErr = CyaSSL_get_error(ssl, 0);
|
|
||||||
if (CyaSSL_write(ssl, ack, sizeof(ack)) < 0) {
|
|
||||||
printf("Write error.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
}
|
|
||||||
printf("Reply sent:\"%s\"\n", ack);
|
|
||||||
}while(readWriteErr == SSL_ERROR_WANT_WRITE && cleanup != 1);
|
|
||||||
/* End do-while write */
|
|
||||||
|
|
||||||
/* free allocated memory */
|
|
||||||
memset(buff, 0, sizeof(buff));
|
|
||||||
CyaSSL_free(ssl);
|
|
||||||
|
|
||||||
/* End: Reply to the Client */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int udp_read_connect(int listenfd)
|
|
||||||
{
|
|
||||||
int bytesRecvd;
|
|
||||||
unsigned char b[MSGLEN];
|
|
||||||
struct sockaddr_in cliAddr;
|
|
||||||
socklen_t clilen = sizeof(cliAddr);
|
|
||||||
|
|
||||||
|
|
||||||
bytesRecvd = (int)recvfrom(listenfd, (char*)b, sizeof(b), MSG_PEEK,
|
|
||||||
(struct sockaddr*)&cliAddr, &clilen);
|
|
||||||
if (bytesRecvd > 0) {
|
|
||||||
if (connect(listenfd, (const struct sockaddr*)&cliAddr,
|
|
||||||
sizeof(cliAddr)) != 0) {
|
|
||||||
printf("udp connect failed.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("recvfrom failed.\n");
|
|
||||||
}
|
|
||||||
/* ensure b is empty upon each call */
|
|
||||||
memset(&b, 0, sizeof(b));
|
|
||||||
return listenfd;
|
|
||||||
}
|
|
||||||
|
|
||||||
int NonBlockingSSL_Accept(CYASSL* ssl)
|
|
||||||
{
|
|
||||||
int select_ret;
|
|
||||||
int currTimeout = 1;
|
|
||||||
int ret = CyaSSL_accept(ssl);
|
|
||||||
int error = CyaSSL_get_error(ssl, 0);
|
|
||||||
int listenfd = (int)CyaSSL_get_fd(ssl);
|
|
||||||
|
|
||||||
while (cleanup != 1 && (ret != SSL_SUCCESS &&
|
|
||||||
(error == SSL_ERROR_WANT_READ ||
|
|
||||||
error == SSL_ERROR_WANT_WRITE))) {
|
|
||||||
if (cleanup == 1) {
|
|
||||||
CyaSSL_free(ssl);
|
|
||||||
CyaSSL_shutdown(ssl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error == SSL_ERROR_WANT_READ)
|
|
||||||
printf("... server would read block\n");
|
|
||||||
else
|
|
||||||
printf("... server would write block\n");
|
|
||||||
|
|
||||||
currTimeout = CyaSSL_dtls_get_current_timeout(ssl);
|
|
||||||
select_ret = dtls_select(listenfd, currTimeout);
|
|
||||||
|
|
||||||
if ((select_ret == TEST_RECV_READY) ||
|
|
||||||
(select_ret == TEST_ERROR_READY)) {
|
|
||||||
ret = CyaSSL_accept(ssl);
|
|
||||||
error = CyaSSL_get_error(ssl, 0);
|
|
||||||
}
|
|
||||||
else if (select_ret == TEST_TIMEOUT && !CyaSSL_dtls(ssl)) {
|
|
||||||
error = SSL_ERROR_WANT_READ;
|
|
||||||
}
|
|
||||||
else if (select_ret == TEST_TIMEOUT && CyaSSL_dtls(ssl) &&
|
|
||||||
CyaSSL_dtls_got_timeout(ssl) >= 0) {
|
|
||||||
error = SSL_ERROR_WANT_READ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
error = SSL_FATAL_ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ret != SSL_SUCCESS) {
|
|
||||||
printf("SSL_accept failed.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dtls_set_nonblocking(int* sockfd)
|
|
||||||
{
|
|
||||||
int flags = fcntl(*sockfd, F_GETFL, 0);
|
|
||||||
if (flags < 0) {
|
|
||||||
printf("fcntl get failed");
|
|
||||||
cleanup = 1;
|
|
||||||
}
|
|
||||||
flags = fcntl(*sockfd, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
if (flags < 0) {
|
|
||||||
printf("fcntl set failed.\n");
|
|
||||||
cleanup = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int dtls_select(int socketfd, int toSec)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
int nfds = socketfd + 1;
|
|
||||||
fd_set recvfds, errfds;
|
|
||||||
struct timeval timeout = { (toSec > 0) ? toSec : 0, 0};
|
|
||||||
|
|
||||||
FD_ZERO(&recvfds);
|
|
||||||
FD_SET(socketfd, &recvfds);
|
|
||||||
FD_ZERO(&errfds);
|
|
||||||
FD_SET(socketfd, &errfds);
|
|
||||||
|
|
||||||
result = select(nfds, &recvfds, NULL, &errfds, &timeout);
|
|
||||||
|
|
||||||
if (result == 0)
|
|
||||||
return TEST_TIMEOUT;
|
|
||||||
else if (result > 0) {
|
|
||||||
if (FD_ISSET(socketfd, &recvfds))
|
|
||||||
return TEST_RECV_READY;
|
|
||||||
else if(FD_ISSET(socketfd, &errfds))
|
|
||||||
return TEST_ERROR_READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TEST_SELECT_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
/* cont short for "continue?", Loc short for "location" */
|
|
||||||
int cont = 0;
|
|
||||||
char caCertLoc[] = "../certs/ca-cert.pem";
|
|
||||||
char servCertLoc[] = "../certs/server-cert.pem";
|
|
||||||
char servKeyLoc[] = "../certs/server-key.pem";
|
|
||||||
CYASSL_CTX* ctx;
|
|
||||||
|
|
||||||
/* "./config --enable-debug" and uncomment next line for debugging */
|
|
||||||
/* CyaSSL_Debugging_ON(); */
|
|
||||||
|
|
||||||
/* Initialize CyaSSL */
|
|
||||||
CyaSSL_Init();
|
|
||||||
|
|
||||||
/* Set ctx to DTLS 1.2 */
|
|
||||||
if ((ctx = CyaSSL_CTX_new(CyaDTLSv1_2_server_method())) == NULL) {
|
|
||||||
printf("CyaSSL_CTX_new error.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load CA certificates */
|
|
||||||
if (CyaSSL_CTX_load_verify_locations(ctx,caCertLoc,0) !=
|
|
||||||
SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", caCertLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load server certificates */
|
|
||||||
if (CyaSSL_CTX_use_certificate_file(ctx, servCertLoc, SSL_FILETYPE_PEM) !=
|
|
||||||
SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", servCertLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* Load server Keys */
|
|
||||||
if (CyaSSL_CTX_use_PrivateKey_file(ctx, servKeyLoc,
|
|
||||||
SSL_FILETYPE_PEM) != SSL_SUCCESS) {
|
|
||||||
printf("Error loading %s, please check the file.\n", servKeyLoc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cont = AwaitDGram(ctx);
|
|
||||||
|
|
||||||
if (cont == 1) {
|
|
||||||
CyaSSL_CTX_free(ctx);
|
|
||||||
CyaSSL_Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
DEPS = ../include/unp.h
|
|
||||||
CC=gcc
|
|
||||||
CFLAGS=-Wall -I ../include -DCYASSL_DTLS
|
|
||||||
OBJ = echoserver.o
|
|
||||||
|
|
||||||
#if you are on a sunOS (System V) machine, you'll need to uncomment
|
|
||||||
#the next line.
|
|
||||||
|
|
||||||
#LIBS=-lsocket
|
|
||||||
%.o: %.c $(DEPS)
|
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
|
||||||
all: server
|
|
||||||
|
|
||||||
server: server-udp.c
|
|
||||||
$(CC) -Wall -o server server-udp.c -I ../include -lcyassl
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -f *.o server
|
|
|
@ -1,96 +0,0 @@
|
||||||
/*
|
|
||||||
* server-udp.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2006-2014 wolfSSL Inc.
|
|
||||||
*
|
|
||||||
* This file is part of CyaSSL.
|
|
||||||
*
|
|
||||||
* CyaSSL is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* CyaSSL is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
||||||
* USA
|
|
||||||
*=============================================================================
|
|
||||||
*
|
|
||||||
* Bare-bones example of a UDP server for instructional/learning purposes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h> /* standard in/out procedures */
|
|
||||||
#include <stdlib.h> /* defines system calls */
|
|
||||||
#include <string.h> /* necessary for memset */
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <sys/socket.h> /* used for all socket calls */
|
|
||||||
#include <netinet/in.h> /* used for sockaddr_in */
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#define SERV_PORT 11111 /* define our server port number */
|
|
||||||
#define MSGLEN 4096 /* limit incoming message size */
|
|
||||||
|
|
||||||
int main (int argc, char** argv)
|
|
||||||
{
|
|
||||||
int sockfd; /* Initialize our socket */
|
|
||||||
int recvLen; /* number of bytes recieved */
|
|
||||||
int msgNum = 0; /* number of msg received */
|
|
||||||
unsigned char buf[MSGLEN]; /* the incoming message */
|
|
||||||
struct sockaddr_in servAddr; /* our server's address */
|
|
||||||
struct sockaddr_in cliAddr; /* the client's address */
|
|
||||||
socklen_t cliAddrLen = sizeof(cliAddr); /* length of address' */
|
|
||||||
|
|
||||||
/* create a UDP/IP socket */
|
|
||||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
|
||||||
perror("cannot create socket");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset((char *)&servAddr, 0, sizeof(servAddr));
|
|
||||||
|
|
||||||
/* host-to-network-long conversion (htonl) */
|
|
||||||
/* host-to-network-short conversion (htons) */
|
|
||||||
servAddr.sin_family = AF_INET;
|
|
||||||
servAddr.sin_addr.s_addr = htonl(INADDR_ANY);
|
|
||||||
servAddr.sin_port = htons(SERV_PORT);
|
|
||||||
|
|
||||||
if (bind(sockfd, (struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) {
|
|
||||||
perror("bind failed");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop, listen for client, print received, reply to client */
|
|
||||||
for (;;) {
|
|
||||||
memset(buf, 0, sizeof(buf));
|
|
||||||
printf("waiting for client message on port %d\n", SERV_PORT);
|
|
||||||
|
|
||||||
recvLen = recvfrom(sockfd, buf, MSGLEN, 0,
|
|
||||||
(struct sockaddr *)&cliAddr, &cliAddrLen);
|
|
||||||
|
|
||||||
printf("heard %d bytes\n", recvLen);
|
|
||||||
|
|
||||||
if (recvLen > 0) {
|
|
||||||
buf[recvLen] = 0;
|
|
||||||
printf("I heard this: \"%s\"\n", buf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("lost the connection to client\n");
|
|
||||||
|
|
||||||
printf("Message #%d received\n", msgNum++);
|
|
||||||
printf("reply sent \"%s\"\n", buf);
|
|
||||||
|
|
||||||
if (sendto(sockfd, buf, sizeof(buf), 0,
|
|
||||||
(struct sockaddr *)&cliAddr, cliAddrLen) < 0) {
|
|
||||||
printf("\"sendto\" failed.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/* continues to loop, use "Ctrl+C" to terminate listening */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue