Unable to push notifications to iPhone in .NET - .PEM certificate problem?


Unable to push notifications to iPhone in .NET - .PEM certificate problem?



I'm attempting to push notifications to my iPhone, which I've successfully done using PHP. However, I'm unable to open a socket connection to Apple's push servers using C#. I don't think there's a problem with the certificate itself, since I'm able to successfully push notifications using this code in PHP:

$ctx = stream_context_create();  stream_context_set_option($ctx, 'ssl', 'local_cert', 'cert.pem');  $fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);  fwrite($fp, $msg); 

When I try to authenticate in C# using the code below, Apple closes the connection right away. I get this exception: "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."

sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Default, false); 

I basically took all my code from this question: http://stackoverflow.com/questions/1056083/c-iphone-push-server

I thought it might be a problem with the certificate since I don't think C# allows you to just load .PEM files programmatically. I used OpenSSL to convert it to a .PFX file, but I still have the same problem.

Any idea how I can troubleshoot this (possible certificate) problem?


How combine TabBar + Navigation with XCode

1:

Best way to manage probably huge photo library with iPhone SDK
This actually turned out to be a problem with .NET 2.0. How make scrolling function with Interface builder on the iPhone? Not sure exactly what it is, although I compiled in Visual Studio 2008 and everything worked great.. How programatically move a UIScrollView to focus in a control above keyboard?
How much of a transition is programming Java to iPhone apps?

42 out of 100 based on 22 user ratings 22 reviews

*