* I2PTunnel SSL cleanup, log SSL exceptions as errors to help find cert problems

This commit is contained in:
zzz
2013-10-18 18:37:25 +00:00
parent 255ebe7efb
commit a78d34ab4b
3 changed files with 14 additions and 1 deletions

View File

@ -19,6 +19,8 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
import javax.net.ssl.SSLException;
import net.i2p.client.streaming.I2PSocket; import net.i2p.client.streaming.I2PSocket;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.ByteArray; import net.i2p.data.ByteArray;
@ -295,6 +297,13 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
s.run(); // same thread s.run(); // same thread
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("After pumping the compressed response: " + compressedOut.getTotalRead() + "/" + compressedOut.getTotalCompressed()); _log.info("After pumping the compressed response: " + compressedOut.getTotalRead() + "/" + compressedOut.getTotalCompressed());
} catch (SSLException she) {
_log.error("SSL error", she);
try {
if (browserout == null)
browserout = _browser.getOutputStream();
browserout.write(ERR_UNAVAILABLE);
} catch (IOException ioe) {}
} catch (IOException ioe) { } catch (IOException ioe) {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("error compressing", ioe); _log.warn("error compressing", ioe);

View File

@ -12,6 +12,8 @@ import java.net.Socket;
import java.net.SocketException; import java.net.SocketException;
import java.util.List; import java.util.List;
import javax.net.ssl.SSLException;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.client.streaming.I2PSocket; import net.i2p.client.streaming.I2PSocket;
import net.i2p.data.ByteArray; import net.i2p.data.ByteArray;
@ -199,6 +201,8 @@ public class I2PTunnelRunner extends I2PAppThread implements I2PSocket.SocketErr
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
if (_log.shouldLog(Log.ERROR)) if (_log.shouldLog(Log.ERROR))
_log.error("Interrupted", ex); _log.error("Interrupted", ex);
} catch (SSLException she) {
_log.error("SSL error", she);
} catch (IOException ex) { } catch (IOException ex) {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Error forwarding", ex); _log.debug("Error forwarding", ex);

View File

@ -54,7 +54,7 @@ public class I2PSSLSocketFactory {
* Loads certs from * Loads certs from
* the ~/.i2p/certificates/ and $I2P/certificates/ directories. * the ~/.i2p/certificates/ and $I2P/certificates/ directories.
*/ */
private SSLSocketFactory initSSLContext(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath) private static SSLSocketFactory initSSLContext(I2PAppContext context, boolean loadSystemCerts, String relativeCertPath)
throws GeneralSecurityException { throws GeneralSecurityException {
Log log = context.logManager().getLog(I2PSSLSocketFactory.class); Log log = context.logManager().getLog(I2PSSLSocketFactory.class);
KeyStore ks; KeyStore ks;