ObjOpenSSL  Diff

Differences From Artifact [cc5dffdd1c]:

To Artifact [3aca96c73c]:


71
72
73
74
75
76
77



78
79
80
81
82
83
84
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87







+
+
+







}

- (void)dealloc
{
	SSL_CTX *ctx_ = ctx;
	SSL *ssl_ = ssl;

	[privateKeyFile release];
	[certificateFile release];

	[super dealloc];

	if (ssl_ != NULL)
		SSL_free(ssl_);
	if (ctx_ != NULL)
		SSL_CTX_free(ctx_);
}
108
109
110
111
112
113
114
115
116







117
118
119
120
121

122



123
124






125
126
127
128
129
130
131
111
112
113
114
115
116
117


118
119
120
121
122
123
124
125
126
127
128

129
130
131
132
133


134
135
136
137
138
139
140
141
142
143
144
145
146







-
-
+
+
+
+
+
+
+




-
+

+
+
+
-
-
+
+
+
+
+
+







	}
}

- (SSLSocket*)accept
{
	SSLSocket *newsock = (SSLSocket*)[super accept];

	if ((ssl = SSL_new(ctx)) == NULL || !SSL_set_fd(ssl, sock)) {
		[super close];
	if ((newsock->ssl = SSL_new(ctx)) == NULL ||
	    !SSL_set_fd(newsock->ssl, newsock->sock)) {
		/* We only want to close the OFTCPSocket */
		newsock->isa = [OFTCPSocket class];
		[newsock close];
		newsock->isa = isa;

		@throw [OFAcceptFailedException newWithClass: isa
						      socket: self];
	}

	SSL_set_accept_state(ssl);
	SSL_set_accept_state(newsock->ssl);

	if (!SSL_use_PrivateKey_file(newsock->ssl, [privateKeyFile cString],
	    SSL_FILETYPE_PEM) || !SSL_use_certificate_file(newsock->ssl,
	    [certificateFile cString], SSL_FILETYPE_PEM) ||
	if (SSL_connect(ssl) != 1) {
		[super close];
	    SSL_accept(newsock->ssl) != 1) {
		/* We only want to close the OFTCPSocket */
		newsock->isa = [OFTCPSocket class];
		[newsock close];
		newsock->isa = isa;

		@throw [OFAcceptFailedException newWithClass: isa
						      socket: self];
	}

	return newsock;
}

205
206
207
208
209
210
211
























212
220
221
222
223
224
225
226
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

	if ((ret = SSL_write(ssl, buf, (int)size)) < 1)
		@throw [OFWriteFailedException newWithClass: isa
						     stream: self
					      requestedSize: size];

	return ret;
}

- (void)setPrivateKeyFile: (OFString*)file
{
	OFString *old = privateKeyFile;
	privateKeyFile = [file copy];
	[old release];
}

- (OFString*)privateKeyFile
{
	return [[privateKeyFile copy] autorelease];
}

- (void)setCertificateFile: (OFString*)file
{
	OFString *old = certificateFile;
	certificateFile = [file copy];
	[old release];
}

- (OFString*)certificateFile
{
	return [[certificateFile copy] autorelease];
}
@end