Skip to content

Commit

Permalink
- Updated to use the new security calls
Browse files Browse the repository at this point in the history
- Updated minimum deployment OS to 10.6
- Fixed some minor cosmetic issues
  • Loading branch information
below committed Jul 16, 2012
1 parent 93458dd commit 8fc6112
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
23 changes: 14 additions & 9 deletions Classes/ApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

}

Expand Down
4 changes: 2 additions & 2 deletions Classes/ioSock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<dataLen; i++) {
Expand Down
6 changes: 4 additions & 2 deletions PushMeBaby.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,12 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
Expand All @@ -261,10 +262,11 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx;
};
name = Release;
Expand Down

0 comments on commit 8fc6112

Please sign in to comment.