ObjOpenSSL  Check-in [20cb421460]

Overview
Comment:Adjust to recent ObjFW changes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 20cb421460c570ac1eea35f5ee70360f8f157ece77f6ff09f8617deff9cc00f7
User & Date: js on 2012-12-19 21:59:32
Other Links: manifest | tags
Context
2013-01-12
22:46
Adjust to recent ObjFW changes. check-in: 41b938d357 user: florob@babelmonkeys.de tags: trunk
2012-12-19
21:59
Adjust to recent ObjFW changes. check-in: 20cb421460 user: js tags: trunk
2012-12-13
20:55
Set of_tls_socket_class. check-in: 1b97015301 user: js tags: trunk
Changes

Modified src/SSLSocket.m from [eff32f791e] to [87768a98f4].

140
141
142
143
144
145
146
147

148
149
150

151
152
153
154
155
156
157
140
141
142
143
144
145
146

147
148
149

150
151
152
153
154
155
156
157







-
+


-
+







			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];
		}

		SSL_set_connect_state(ssl);

		if ((privateKeyFile != nil && !SSL_use_PrivateKey_file(ssl,
		    [privateKeyFile cStringWithEncoding:
		    [privateKeyFile cStringUsingEncoding:
		    OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM)) ||
		    (certificateFile != nil && !SSL_use_certificate_file(ssl,
		    [certificateFile cStringWithEncoding:
		    [certificateFile cStringUsingEncoding:
		    OF_STRING_ENCODING_NATIVE], SSL_FILETYPE_PEM)) ||
		    SSL_connect(ssl) != 1) {
			close(sock);
			sock = INVALID_SOCKET;
			@throw [OFInitializationFailedException
			    exceptionWithClass: [self class]];
		}
190
191
192
193
194
195
196
197

198
199
200

201
202
203
204
205
206
207
190
191
192
193
194
195
196

197
198
199

200
201
202
203
204
205
206
207







-
+


-
+







				  host: host
				  port: port];
	}

	SSL_set_connect_state(ssl);

	if ((privateKeyFile != nil && !SSL_use_PrivateKey_file(ssl,
	    [privateKeyFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [privateKeyFile cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
	    SSL_FILETYPE_PEM)) || (certificateFile != nil &&
	    !SSL_use_certificate_file(ssl, [certificateFile
	    cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
	    SSL_FILETYPE_PEM)) || SSL_connect(ssl) != 1) {
		[super close];
		@throw [OFConnectionFailedException
		    exceptionWithClass: [self class]
				socket: self
				  host: host
				  port: port];
222
223
224
225
226
227
228
229

230
231

232
233
234
235
236
237
238
222
223
224
225
226
227
228

229
230

231
232
233
234
235
236
237
238







-
+

-
+







		@throw [OFAcceptFailedException exceptionWithClass: [self class]
							    socket: self];
	}

	SSL_set_accept_state(newSocket->ssl);

	if (!SSL_use_PrivateKey_file(newSocket->ssl, [privateKeyFile
	    cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
	    SSL_FILETYPE_PEM) || !SSL_use_certificate_file(newSocket->ssl,
	    [certificateFile cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    [certificateFile cStringUsingEncoding: OF_STRING_ENCODING_NATIVE],
	    SSL_FILETYPE_PEM) || SSL_accept(newSocket->ssl) != 1) {
		/* We only want to close the OFTCPSocket */
		object_setClass(newSocket, [OFTCPSocket class]);
		[newSocket close];
		object_setClass(newSocket, object_getClass(self));

		@throw [OFAcceptFailedException exceptionWithClass: [self class]
371
372
373
374
375
376
377
378
379


380
381
382
383
384
385
386
371
372
373
374
375
376
377


378
379
380
381
382
383
384
385
386







-
-
+
+







		length = SSL_get_finished(ssl, buffer, 64);
	} else {
		/* peer sent the finished message */
		length = SSL_get_peer_finished(ssl, buffer, 64);
	}

	data = [OFDataArray dataArray];
	[data addItemsFromCArray: buffer
			   count: length];
	[data addItems: buffer
		 count: length];

	return data;
}

- (X509Certificate*)peerCertificate
{
	X509 *certificate = SSL_get_peer_certificate(ssl);

Modified src/X509Certificate.m from [9922d7f262] to [79d37925ec].

46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60







-
+








	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFFile *fd = [OFFile fileWithPath: file
					     mode: @"r"];
		OFDataArray *data = [fd readDataArrayTillEndOfStream];
		[fd close];
		const unsigned char *dataCArray = [data cArray];
		const unsigned char *dataCArray = [data items];
		crt = d2i_X509(NULL, &dataCArray, [data count]);
		[pool release];
		if (crt == NULL)
			@throw [OFInitializationFailedException
				    exceptionWithClass: [self class]];
	} @catch (id e) {
		[self release];