Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ServerSocket to SSL

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can change

to

and it will work fine?

I've never used SSL stuff before and just want to make sure I have it right before I go through with it. I have made a huge IM chat program and am trying to make it better (and learn new things). Do I have to change any of my other code? Here is my whole server code (modified to cut down on code lines and hide certain things I don't want people to know...


Would I have to change my client code too (change it to using SSL)?
Thanks,
John Price aka cc11rocks
 
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code looks alright to me. And yes, you need to start using SSLSocket in the client as well, using SSLSocketFactory. Fortunately, nothing needs to change in both the client and the server except the lines that create the ServerSocket (server) and Socket (client). You can even keep the reference types as ServerSocket and Socket, as SSLServerSocket and SSLSocket provide no extra methods you need. That way you don't even need the cast to SSLServerSocket you have.
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic