I want to create a socket server in cocoa, using AsyncSockets and connect with Java. Enabling SSL works if Java is the server and cocoa the client, but I require the other way around to work. I guess I'm just missing some settings within cocoa, so heres my java code: I'm starting the client by passing:
-Djavax.net.ssl.trustStore=${project_loc}/myKeystore 
-Djavax.net.ssl.trustStorePassword=myPass
-Djavax.net.debug=all
_
public class Client {
    public static void main(String[] arstring) {
        try {
            SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory
                    .getDefault();
            SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(
                    "localhost", 9999);
            InputStream inputstream = System.in;
            InputStreamReader inputstreamreader = new InputStreamReader(
                    inputstream);
            BufferedReader bufferedreader = new BufferedReader(
                    inputstreamreader);
            OutputStream outputstream = sslsocket.getOutputStream();
            OutputStreamWriter outputstreamwriter = new OutputStreamWriter(
                    outputstream);
            BufferedWriter bufferedwriter = new BufferedWriter(
                    outputstreamwriter);
            String string = null;
            while ((string = bufferedreader.readLine()) != null) {
                bufferedwriter.write(string + "\r\n");
                bufferedwriter.flush();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
}
and bits of my cocoa code:
- (void)socket:(GCDAsyncSocket *)socket didAcceptNewSocket:(GCDAsyncSocket *)newSocket
{
    NSLog(@"new conn");
    // read again for further messages with undefined timeout
    NSMutableDictionary *settings = [NSMutableDictionary dictionaryWithCapacity:3];
    [settings setObject:[NSNumber numberWithBool:NO]
                 forKey:(NSString *)kCFStreamSSLValidatesCertificateChain];
    [settings setObject:(NSString*)kCFStreamPropertySocketSecurityLevel
                 forKey:(NSString*)kCFStreamSocketSecurityLevelNegotiatedSSL];
    DDLogVerbose(@"Starting TLS with settings:\n%@", settings);
    [newSocket startTLS:settings];
    [newSocket readDataToData:[GCDAsyncSocket CRLFData] withTimeout:-1 tag:0];
}
as soon as I send a message from the java client to the cocoa server, I get following error:
main, READ: TLSv1 Handshake, length = 117
main, handling exception: javax.net.ssl.SSLProtocolException: Illegal client handshake msg, 1
main, SEND TLSv1 ALERT:  fatal, description = unexpected_message
main, WRITE: TLSv1 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 01 00 02 02 0A                               .......
main, called closeSocket()
javax.net.ssl.SSLProtocolException: Illegal client handshake msg, 1
Does anybody have a hint how to use it properly?