[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl] How do I create a server socket?




Hi!
I'm trying to create a server socket but I can't get it right(and yes I
don't know what I'm doing...)
this is the first time with SSL sockets for me so if someone could help
it would make my life much easier :)


when I do the "context.toString()" it says "Avalible certificates" so I
guess that I haven been able to load any certificate...



<---------------------------------------------------------------------------
----------------->

import java.io.*;
import java.net.*;
import java.util.*;
import java.security.cert.CertificateException;
import iaik.security.ssl.SSLCertificate;
import iaik.security.ssl.*;
import iaik.security.rsa.*;
import iaik.x509.*;
import iaik.utils.*;

class httpServer {

    public static void main(String args[])  {
        SSLServerSocket srvSock = null;
        SSLServerContext context = new SSLServerContext();
        Socket cliSock = null;
        int connects = 0;

        try  {
          try {
            X509Certificate chain = new X509Certificate();
            InputStream inStream = new FileInputStream("trusted.cer");
            chain = new X509Certificate(inStream);
            inStream.close();

            System.out.println(context.toString());
            srvSock = new SSLServerSocket(60337,context);
          } catch(CertificateException e){ System.out.println("CertErr:
"+ e);}
            while (connects < 3)   {
                cliSock = srvSock.accept();
                ServiceClient(cliSock);
                connects++;
            }
            srvSock.close();
         }  catch (IOException e)  {
              System.out.println("Error: " + e);
         }

    }
}


<---------------------------------------------------------------------------
----------------->

-Mattias Holm
--
Mailinglist-archive at
http://jcewww.iaik.at/mailarchive/iaik-ssl/sslthreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content:
UNSUBSCRIBE iaik-ssl