ObjOpenSSL  Diff

Differences From Artifact [65a015edb7]:

To Artifact [c52dc2d9da]:


1
2


3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9
10

-
+
+







/*
 * Copyright (c) 2011, 2012, 2013, 2014, Jonathan Schleifer <js@webkeks.org>
 * Copyright (c) 2011, 2012, 2013, 2014, 2015
 *     Jonathan Schleifer <js@webkeks.org>
 * Copyright (c) 2011, Florian Zeitz <florob@babelmonkeys.de>
 * Copyright (c) 2011, Jos Kuijpers <jos@kuijpersvof.nl>
 *
 * https://webkeks.org/git/?p=objopenssl.git
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
28
29
30
31
32
33
34

35
36
37
38
39
40
41
42
43

44
45
46
47
48
49
50
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53







+









+








#include <openssl/crypto.h>
#include <openssl/err.h>

#import <ObjFW/OFThread.h>
#import <ObjFW/OFHTTPRequest.h>
#import <ObjFW/OFDataArray.h>
#import <ObjFW/OFSystemInfo.h>

#import <ObjFW/OFAcceptFailedException.h>
#import <ObjFW/OFConnectionFailedException.h>
#import <ObjFW/OFInitializationFailedException.h>
#import <ObjFW/OFInvalidArgumentException.h>
#import <ObjFW/OFNotConnectedException.h>
#import <ObjFW/OFOutOfRangeException.h>
#import <ObjFW/OFReadFailedException.h>
#import <ObjFW/OFWriteFailedException.h>

#import <ObjFW/macros.h>
#import <ObjFW/threading.h>

#import "SSLSocket.h"
#import "SSLInvalidCertificateException.h"
#import "X509Certificate.h"

145
146
147
148
149
150
151
152

153
154
155
156
157
158
159
148
149
150
151
152
153
154

155
156
157
158
159
160
161
162







-
+







		    exceptionWithHost: nil
				 port: 0
			       socket: self];
	}

	SSL_set_connect_state(_SSL);

	encoding = [OFString nativeOSEncoding];
	encoding = [OFSystemInfo native8BitEncoding];

	if ((_privateKeyFile != nil && !SSL_use_PrivateKey_file(_SSL,
	    [_privateKeyFile cStringWithEncoding: encoding],
	    SSL_FILETYPE_PEM)) || (_certificateFile != nil &&
	    !SSL_use_certificate_file(_SSL, [_certificateFile
	    cStringWithEncoding: encoding],
	    SSL_FILETYPE_PEM)) || SSL_connect(_SSL) != 1) {
186
187
188
189
190
191
192
193


194
195
196
197
198
199
200
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
204







-
+
+







	}

	if (_requestsClientCertificates)
		SSL_set_verify(client->_SSL, SSL_VERIFY_PEER, NULL);

	SSL_set_accept_state(client->_SSL);

	encoding = [OFString nativeOSEncoding];
	encoding = [OFSystemInfo native8BitEncoding];

	if (!SSL_use_PrivateKey_file(client->_SSL, [_privateKeyFile
	    cStringWithEncoding: encoding],
	    SSL_FILETYPE_PEM) || !SSL_use_certificate_file(client->_SSL,
	    [_certificateFile cStringWithEncoding: encoding],
	    SSL_FILETYPE_PEM) || SSL_accept(client->_SSL) != 1) {
		[client SSL_super_close];
		@throw [OFAcceptFailedException exceptionWithSocket: self];