ObjOpenSSL  Check-in [7ea66a81da]

Overview
Comment:Adjust to ObjFW changes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7ea66a81daffbc4aa6c42c9f0a747b113d5c020e60ccea3346ba8d2e52b5ca9f
User & Date: js on 2015-03-01 19:49:50
Other Links: manifest | tags
Context
2015-05-05
13:18
configure: Use rpath check-in: 2dd19e51ce user: js tags: trunk
2015-03-01
19:49
Adjust to ObjFW changes check-in: 7ea66a81da user: js tags: trunk
2015-01-05
21:43
Adjust to ObjFW changes check-in: 089eb98b69 user: js tags: trunk
Changes

Modified src/SSLSocket.m from [c52dc2d9da] to [50ced396e8].

181
182
183
184
185
186
187

188


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

204


205
206
207
208
209
210
211
181
182
183
184
185
186
187
188

189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206

207
208
209
210
211
212
213
214
215







+
-
+
+















+
-
+
+







{
	SSLSocket *client = (SSLSocket*)[super accept];
	of_string_encoding_t encoding;

	if ((client->_SSL = SSL_new(ctx)) == NULL ||
	    !SSL_set_fd(client->_SSL, client->_socket)) {
		[client SSL_super_close];
		/* FIXME: Get a proper errno */
		@throw [OFAcceptFailedException exceptionWithSocket: self];
		@throw [OFAcceptFailedException exceptionWithSocket: self
							      errNo: 0];
	}

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

	SSL_set_accept_state(client->_SSL);

	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];
		/* FIXME: Get a proper errno */
		@throw [OFAcceptFailedException exceptionWithSocket: self];
		@throw [OFAcceptFailedException exceptionWithSocket: self
							      errNo: 0];
	}

	return client;
}

- (void)close
{
227
228
229
230
231
232
233
234

235
236
237
238


239
240

241
242
243
244
245
246
247
248
249
250
251
252
253
231
232
233
234
235
236
237

238




239
240


241






242
243
244
245
246
247
248







-
+
-
-
-
-
+
+
-
-
+
-
-
-
-
-
-








	if (length > INT_MAX)
		@throw [OFOutOfRangeException exception];

	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];

	if (_atEndOfStream) {
	if (_atEndOfStream)
		OFReadFailedException *e;

		e = [OFReadFailedException exceptionWithObject: self
					       requestedLength: length];
		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: length
#ifndef _WIN32
		e->_errNo = ENOTCONN;
							    errNo: ENOTCONN];
#else
		e->_errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if ((ret = SSL_read(_SSL, buffer, (int)length)) < 0) {
		if (SSL_get_error(_SSL, ret) == SSL_ERROR_WANT_READ)
			return 0;

		@throw [OFReadFailedException exceptionWithObject: self
						  requestedLength: length];
264
265
266
267
268
269
270
271

272
273
274
275


276
277
278

279
280
281
282
283
284
285
286
287
288
289
290
291
259
260
261
262
263
264
265

266




267
268



269






270
271
272
273
274
275
276







-
+
-
-
-
-
+
+
-
-
-
+
-
-
-
-
-
-







{
	if (length > INT_MAX)
		@throw [OFOutOfRangeException exception];

	if (_socket == INVALID_SOCKET)
		@throw [OFNotConnectedException exceptionWithSocket: self];

	if (_atEndOfStream) {
	if (_atEndOfStream)
		OFWriteFailedException *e;

		e = [OFWriteFailedException exceptionWithObject: self
						requestedLength: length];
		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length

#ifndef _WIN32
		e->_errNo = ENOTCONN;
							     errNo: ENOTCONN];
#else
		e->_errNo = WSAENOTCONN;
#endif

		@throw e;
	}

	if (SSL_write(_SSL, buffer, (int)length) < length)
		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length];
}

- (bool)hasDataInReadBuffer