Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0eb24512 authored by cketti's avatar cketti
Browse files

Merge pull request #417 from bk2204/tsf-starttls

Use TrustedSocketFactory for STARTTLS
parents f4ebc098 1bfb78ee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2504,8 +2504,8 @@ public class ImapStore extends Store {
                        sslContext.init(null, new TrustManager[] {
                                            TrustManagerFactory.get(mSettings.getHost(), secure)
                                        }, new SecureRandom());
                        mSocket = sslContext.getSocketFactory().createSocket(mSocket, mSettings.getHost(), mSettings.getPort(),
                                  true);
                        mSocket = TrustedSocketFactory.createSocket(sslContext, mSocket,
                                mSettings.getHost(), mSettings.getPort(), true);
                        mSocket.setSoTimeout(Store.SOCKET_READ_TIMEOUT);
                        mIn = new PeekableInputStream(new BufferedInputStream(mSocket
                                                      .getInputStream(), 1024));
+2 −2
Original line number Diff line number Diff line
@@ -359,8 +359,8 @@ public class Pop3Store extends Store {
                        sslContext.init(null, new TrustManager[] {
                                            TrustManagerFactory.get(mHost, secure)
                                        }, new SecureRandom());
                        mSocket = sslContext.getSocketFactory().createSocket(mSocket, mHost, mPort,
                                  true);
                        mSocket = TrustedSocketFactory.createSocket(sslContext, mSocket, mHost,
                                mPort, true);
                        mSocket.setSoTimeout(Store.SOCKET_READ_TIMEOUT);
                        mIn = new BufferedInputStream(mSocket.getInputStream(), 1024);
                        mOut = new BufferedOutputStream(mSocket.getOutputStream(), 512);
+8 −0
Original line number Diff line number Diff line
@@ -85,6 +85,14 @@ public class TrustedSocketFactory {
        return socket;
    }

    public static Socket createSocket(SSLContext sslContext, Socket s, String host, int port,
            boolean autoClose) throws IOException {
        SSLSocket socket = (SSLSocket) sslContext.getSocketFactory().createSocket(s, host, port, autoClose);
        hardenSocket(socket);

        return socket;
    }

    private static void hardenSocket(SSLSocket sock) {
        if (ENABLED_CIPHERS != null) {
            sock.setEnabledCipherSuites(ENABLED_CIPHERS);
+2 −2
Original line number Diff line number Diff line
@@ -304,8 +304,8 @@ public class SmtpTransport extends Transport {
                    sslContext.init(null, new TrustManager[] {
                                        TrustManagerFactory.get(mHost, secure)
                                    }, new SecureRandom());
                    mSocket = sslContext.getSocketFactory().createSocket(mSocket, mHost, mPort,
                              true);
                    mSocket = TrustedSocketFactory.createSocket(sslContext, mSocket, mHost,
                              mPort, true);
                    mIn = new PeekableInputStream(new BufferedInputStream(mSocket.getInputStream(),
                                                  1024));
                    mOut = mSocket.getOutputStream();