ObjFW  Check-in [50fd2e6e50]

Overview
Comment:Make Secure Transport work on macOS Leopard
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 50fd2e6e50b626a8301f1eeb4c1c2383b1946c2dc8792fa40ad7e63388131c18
User & Date: js on 2021-12-05 17:39:41
Other Links: manifest | tags
Context
2021-12-07
19:01
Use UINT*_C for swap macros check-in: de72eaa6ea user: js tags: trunk
2021-12-05
17:39
Make Secure Transport work on macOS Leopard check-in: 50fd2e6e50 user: js tags: trunk
17:30
Make GCC 4.0 happy again check-in: 57ff42efa2 user: js tags: trunk
Changes

Modified configure.ac from [4ede6e2bd3] to [70eb30ec3e].

1547
1548
1549
1550
1551
1552
1553


1554
1555
1556
1557
1558
1559
1560

			tls_support="Secure Transport"
			TLS_LIBS="-framework Foundation $TLS_LIBS"
			TLS_LIBS="-framework Security $TLS_LIBS"

			AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M,
				"OFSecureTransportTLSStream.m")


		], [])

		LIBS="$old_LIBS"
	])

	AS_IF([test x"$tls_support" = x"no"], [
		PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [







>
>







1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562

			tls_support="Secure Transport"
			TLS_LIBS="-framework Foundation $TLS_LIBS"
			TLS_LIBS="-framework Security $TLS_LIBS"

			AC_SUBST(OF_SECURE_TRANSPORT_TLS_STREAM_M,
				"OFSecureTransportTLSStream.m")

			AC_CHECK_FUNCS(SSLCreateContext)
		], [])

		LIBS="$old_LIBS"
	])

	AS_IF([test x"$tls_support" = x"no"], [
		PKG_CHECK_MODULES(gnutls, [gnutls >= 3.5.0], [

Modified src/tls/OFSecureTransportTLSStream.m from [05236b5563] to [30fa947c05].

10
11
12
13
14
15
16


17
18
19
20
21
22
23
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#import "OFSecureTransportTLSStream.h"

#import "OFAlreadyConnectedException.h"
#import "OFNotOpenException.h"
#import "OFReadFailedException.h"
#import "OFTLSHandshakeFailedException.h"







>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <errno.h>

#import "OFSecureTransportTLSStream.h"

#import "OFAlreadyConnectedException.h"
#import "OFNotOpenException.h"
#import "OFReadFailedException.h"
#import "OFTLSHandshakeFailedException.h"
115
116
117
118
119
120
121

122



123
124
125
126
127
128
129
	if (_context == NULL)
		@throw [OFNotOpenException exceptionWithObject: self];

	[_host release];
	_host = nil;

	SSLClose(_context);

	CFRelease(_context);



	_context = NULL;

	[super close];
}

- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
{







>

>
>
>







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
	if (_context == NULL)
		@throw [OFNotOpenException exceptionWithObject: self];

	[_host release];
	_host = nil;

	SSLClose(_context);
#ifdef HAVE_SSLCREATECONTEXT
	CFRelease(_context);
#else
	SSLDisposeContext(_context);
#endif
	_context = NULL;

	[super close];
}

- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length
{
180
181
182
183
184
185
186

187
188



189
190
191
192
193
194
195
	    OFTLSStreamErrorCodeInitializationFailed;
	id exception = nil;
	OSStatus status;

	if (_context != NULL)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];


	if ((_context = SSLCreateContext(kCFAllocatorDefault, kSSLClientSide,
	    kSSLStreamType)) == NULL)



		@throw [OFTLSHandshakeFailedException
		    exceptionWithStream: self
				   host: host
			      errorCode: initFailedErrorCode];

	if (SSLSetIOFuncs(_context, readFunc, writeFunc) != noErr ||
	    SSLSetConnection(_context, self) != noErr)







>


>
>
>







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
	    OFTLSStreamErrorCodeInitializationFailed;
	id exception = nil;
	OSStatus status;

	if (_context != NULL)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

#ifdef HAVE_SSLCREATECONTEXT
	if ((_context = SSLCreateContext(kCFAllocatorDefault, kSSLClientSide,
	    kSSLStreamType)) == NULL)
#else
	if (SSLNewContext(false, &_context) != noErr)
#endif
		@throw [OFTLSHandshakeFailedException
		    exceptionWithStream: self
				   host: host
			      errorCode: initFailedErrorCode];

	if (SSLSetIOFuncs(_context, readFunc, writeFunc) != noErr ||
	    SSLSetConnection(_context, self) != noErr)