import java.io.OutputStreamWriter;
import java.net.Socket;
+import javax.net.ssl.SSLException;
+
import be.nikiroo.utils.Version;
import be.nikiroo.utils.serial.Exporter;
import be.nikiroo.utils.serial.Importer;
*/
public void connect() {
try {
- in = new BufferedReader(new InputStreamReader(s.getInputStream(),
- "UTF-8"));
+ in = new BufferedReader(
+ new InputStreamReader(s.getInputStream(), "UTF-8"));
try {
out = new OutputStreamWriter(s.getOutputStream(), "UTF-8");
try {
in = null;
}
} catch (Exception e) {
+ if (e instanceof SSLException) {
+ String ciphers = "";
+ for (String cipher : Server.getAnonCiphers()) {
+ if (!ciphers.isEmpty()) {
+ ciphers += ", ";
+ }
+ ciphers += cipher;
+ }
+
+ e = new SSLException(
+ "SSL error (available SSL ciphers: " + ciphers + ")",
+ e);
+ }
+
onError(e);
} finally {
try {
* @throws ClassNotFoundException
* if a class described in the serialised data cannot be found
*/
- protected Object sendObject(Object data) throws IOException,
- NoSuchFieldException, NoSuchMethodException, ClassNotFoundException {
+ protected Object sendObject(Object data)
+ throws IOException, NoSuchFieldException, NoSuchMethodException,
+ ClassNotFoundException {
synchronized (lock) {
- String rep = sendString(new Exporter().append(data).toString(true,
- true));
+ String rep = sendString(
+ new Exporter().append(data).toString(true, true));
if (rep != null) {
return new Importer().read(rep).getValue();
}
* @throws java.lang.NullPointerException
* if the counter part has no data to send
*/
- protected Object recObject() throws IOException, NoSuchFieldException,
- NoSuchMethodException, ClassNotFoundException,
- java.lang.NullPointerException {
+ protected Object recObject()
+ throws IOException, NoSuchFieldException, NoSuchMethodException,
+ ClassNotFoundException, java.lang.NullPointerException {
String str = recString();
if (str == null) {
throw new NullPointerException("No more data available");
tracer.trace(name + ": server starting on port " + port + " ("
+ (ssl ? "SSL" : "plain text") + ")");
+ String ciphers = "";
+ for (String cipher : getAnonCiphers()) {
+ if (!ciphers.isEmpty()) {
+ ciphers += ", ";
+ }
+ ciphers += cipher;
+ }
+ tracer.trace("Available SSL ciphers: " + ciphers);
+
while (started && !exiting) {
count(1);
final Socket s = ss.accept();
*
* @return the list of such supported ciphers
*/
- private static String[] getAnonCiphers() {
+ public static String[] getAnonCiphers() {
List<String> anonCiphers = new ArrayList<String>();
for (String cipher : ((SSLSocketFactory) SSLSocketFactory.getDefault())
.getSupportedCipherSuites()) {