diff --git a/Classes/ApplicationDelegate.m b/Classes/ApplicationDelegate.m index 2bd171e..1349c9e 100644 --- a/Classes/ApplicationDelegate.m +++ b/Classes/ApplicationDelegate.m @@ -95,11 +95,11 @@ - (void)connect { // Create certificate. NSData *certificateData = [NSData dataWithContentsOfFile:self.certificate]; - CSSM_DATA data; - data.Data = (uint8 *)[certificateData bytes]; - data.Length = [certificateData length]; - result = SecCertificateCreateFromData(&data, CSSM_CERT_X_509v3, CSSM_CERT_ENCODING_BER, &certificate);// NSLog(@"SecCertificateCreateFromData(): %d", result); - + + certificate = SecCertificateCreateWithData(kCFAllocatorDefault, (CFDataRef)certificateData); + if (certificate == NULL) + NSLog (@"SecCertificateCreateWithData failled"); + // Create identity. result = SecIdentityCreateWithCertificate(keychain, certificate, &identity);// NSLog(@"SecIdentityCreateWithCertificate(): %d", result); @@ -128,13 +128,16 @@ - (void)disconnect { result = SSLClose(context);// NSLog(@"SSLClose(): %d", result); // Release identity. - CFRelease(identity); + if (identity != NULL) + CFRelease(identity); // Release certificate. - CFRelease(certificate); + if (certificate != NULL) + CFRelease(certificate); // Release keychain. - CFRelease(keychain); + if (keychain != NULL) + CFRelease(keychain); // Close connection to server. close((int)socket); @@ -194,7 +197,9 @@ - (IBAction)push:(id)sender { // Send message over SSL. size_t processed = 0; - OSStatus result = SSLWrite(context, &message, (pointer - message), &processed);// NSLog(@"SSLWrite(): %d %d", result, processed); + OSStatus result = SSLWrite(context, &message, (pointer - message), &processed); + if (result != noErr) + NSLog(@"SSLWrite(): %d %zd", result, processed); } diff --git a/Classes/ioSock.c b/Classes/ioSock.c index 53f52ac..5ca781d 100755 --- a/Classes/ioSock.c +++ b/Classes/ioSock.c @@ -288,7 +288,7 @@ OSStatus AcceptClientConnection( { struct sockaddr_in addr; int sock; - int len; + socklen_t len; len = sizeof(struct sockaddr_in); sock = accept((int)listenSock, (struct sockaddr *) &addr, &len); @@ -413,7 +413,7 @@ OSStatus SocketWrite( if(oneAtATime && (*dataLength > 1)) { UInt32 i; UInt32 outLen; - UInt32 thisMove; + size_t thisMove; outLen = 0; for(i=0; i