{"action":"created","comment":{"url":"https://api.github.com/repos/haiwen/seadroid/pulls/comments/22429391","id":22429391,"diff_hunk":"@@ -0,0 +1,185 @@\n+package com.seafile.seadroid2;\n+\n+import android.os.Build;\n+\n+import java.io.IOException;\n+import java.net.InetAddress;\n+import java.net.Socket;\n+import java.security.KeyManagementException;\n+import java.security.NoSuchAlgorithmException;\n+import java.security.SecureRandom;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+import javax.net.ssl.KeyManager;\n+import javax.net.ssl.SSLContext;\n+import javax.net.ssl.SSLSocket;\n+import javax.net.ssl.SSLSocketFactory;\n+import javax.net.ssl.TrustManager;\n+\n+/**\n+ * Custom SSLSocketFactory.\n+ *\n+ * Used to manually select TLS protocol versions.\n+ *\n+ * based on:\n+ * https://stackoverflow.com/questions/1037590/which-cipher-suites-to-enable-for-ssl-socket\n+ */\n+public class SSLSeafileSocketFactory extends SSLSocketFactory {\n+\n+    private SSLContext m_ctx;\n+    private String[] m_ciphers;\n+    private String[] m_protocols;\n+\n+    public SSLSeafileSocketFactory(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws NoSuchAlgorithmException, KeyManagementException\n+    {\n+        m_ctx = SSLContext.getInstance(\"TLS\");\n+        m_ctx.init(km, tm, random);\n+\n+        m_protocols = GetProtocolList();\n+        m_ciphers = GetCipherList();\n+    }\n+\n+    public String[] getDefaultCipherSuites()\n+    {\n+        return m_ciphers;\n+    }\n+\n+    public String[] getSupportedCipherSuites()\n+    {\n+        return m_ciphers;\n+    }\n+\n+    public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException\n+    {\n+        SSLSocketFactory factory = m_ctx.getSocketFactory();\n+        SSLSocket ss = (SSLSocket)factory.createSocket(s, host, port, autoClose);\n+\n+        ss.setEnabledProtocols(m_protocols);\n+        ss.setEnabledCipherSuites(m_ciphers);\n+\n+        return ss;\n+    }\n+\n+    public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException\n+    {\n+        SSLSocketFactory factory = m_ctx.getSocketFactory();\n+        SSLSocket ss = (SSLSocket)factory.createSocket(address, port, localAddress, localPort);\n+\n+        ss.setEnabledProtocols(m_protocols);\n+        ss.setEnabledCipherSuites(m_ciphers);\n+\n+        return ss;\n+    }\n+\n+    public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException\n+    {\n+        SSLSocketFactory factory = m_ctx.getSocketFactory();\n+        SSLSocket ss = (SSLSocket)factory.createSocket(host, port, localHost, localPort);\n+\n+        ss.setEnabledProtocols(m_protocols);\n+        ss.setEnabledCipherSuites(m_ciphers);\n+\n+        return ss;\n+    }\n+\n+    public Socket createSocket(InetAddress host, int port) throws IOException\n+    {\n+        SSLSocketFactory factory = m_ctx.getSocketFactory();\n+        SSLSocket ss = (SSLSocket)factory.createSocket(host, port);\n+\n+        ss.setEnabledProtocols(m_protocols);\n+        ss.setEnabledCipherSuites(m_ciphers);\n+\n+        return ss;\n+    }\n+\n+    public Socket createSocket(String host, int port) throws IOException\n+    {\n+        SSLSocketFactory factory = m_ctx.getSocketFactory();\n+        SSLSocket ss = (SSLSocket)factory.createSocket(host, port);\n+\n+        ss.setEnabledProtocols(m_protocols);\n+        ss.setEnabledCipherSuites(m_ciphers);\n+\n+        return ss;\n+    }\n+\n+    protected String[] GetProtocolList()","path":"src/com/seafile/seadroid2/SSLSeafileSocketFactory.java","position":109,"original_position":109,"commit_id":"7eb70ba0398c79791e0bd98e3270030992d94908","original_commit_id":"7eb70ba0398c79791e0bd98e3270030992d94908","user":{"login":"lins05","id":717363,"avatar_url":"https://avatars.githubusercontent.com/u/717363?v=3","gravatar_id":"","url":"https://api.github.com/users/lins05","html_url":"https://github.com/lins05","followers_url":"https://api.github.com/users/lins05/followers","following_url":"https://api.github.com/users/lins05/following{/other_user}","gists_url":"https://api.github.com/users/lins05/gists{/gist_id}","starred_url":"https://api.github.com/users/lins05/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lins05/subscriptions","organizations_url":"https://api.github.com/users/lins05/orgs","repos_url":"https://api.github.com/users/lins05/repos","events_url":"https://api.github.com/users/lins05/events{/privacy}","received_events_url":"https://api.github.com/users/lins05/received_events","type":"User","site_admin":false},"body":"use camelCase for method names, but don't capitalize the first letter.","created_at":"2015-01-03T04:01:55Z","updated_at":"2015-01-03T04:01:55Z","html_url":"https://github.com/haiwen/seadroid/pull/220#discussion_r22429391","pull_request_url":"https://api.github.com/repos/haiwen/seadroid/pulls/220","_links":{"self":{"href":"https://api.github.com/repos/haiwen/seadroid/pulls/comments/22429391"},"html":{"href":"https://github.com/haiwen/seadroid/pull/220#discussion_r22429391"},"pull_request":{"href":"https://api.github.com/repos/haiwen/seadroid/pulls/220"}}},"pull_request":{"url":"https://api.github.com/repos/haiwen/seadroid/pulls/220","id":26776922,"html_url":"https://github.com/haiwen/seadroid/pull/220","diff_url":"https://github.com/haiwen/seadroid/pull/220.diff","patch_url":"https://github.com/haiwen/seadroid/pull/220.patch","issue_url":"https://api.github.com/repos/haiwen/seadroid/issues/220","number":220,"state":"open","locked":false,"title":"TLS protocol and cipher list improvements","user":{"login":"forouher","id":676900,"avatar_url":"https://avatars.githubusercontent.com/u/676900?v=3","gravatar_id":"","url":"https://api.github.com/users/forouher","html_url":"https://github.com/forouher","followers_url":"https://api.github.com/users/forouher/followers","following_url":"https://api.github.com/users/forouher/following{/other_user}","gists_url":"https://api.github.com/users/forouher/gists{/gist_id}","starred_url":"https://api.github.com/users/forouher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forouher/subscriptions","organizations_url":"https://api.github.com/users/forouher/orgs","repos_url":"https://api.github.com/users/forouher/repos","events_url":"https://api.github.com/users/forouher/events{/privacy}","received_events_url":"https://api.github.com/users/forouher/received_events","type":"User","site_admin":false},"body":"* Enable TLS 1.1+\r\n* Overwrite Android's default cipherlist with a more secure one.\r\n\r\n(see patches for more detailed explanations)","created_at":"2015-01-03T00:42:38Z","updated_at":"2015-01-03T04:01:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"533530e78ecb22c0151d52a768468e632391e3fb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/haiwen/seadroid/pulls/220/commits","review_comments_url":"https://api.github.com/repos/haiwen/seadroid/pulls/220/comments","review_comment_url":"https://api.github.com/repos/haiwen/seadroid/pulls/comments/{number}","comments_url":"https://api.github.com/repos/haiwen/seadroid/issues/220/comments","statuses_url":"https://api.github.com/repos/haiwen/seadroid/statuses/7eb70ba0398c79791e0bd98e3270030992d94908","head":{"label":"forouher:fix/tls","ref":"fix/tls","sha":"7eb70ba0398c79791e0bd98e3270030992d94908","user":{"login":"forouher","id":676900,"avatar_url":"https://avatars.githubusercontent.com/u/676900?v=3","gravatar_id":"","url":"https://api.github.com/users/forouher","html_url":"https://github.com/forouher","followers_url":"https://api.github.com/users/forouher/followers","following_url":"https://api.github.com/users/forouher/following{/other_user}","gists_url":"https://api.github.com/users/forouher/gists{/gist_id}","starred_url":"https://api.github.com/users/forouher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forouher/subscriptions","organizations_url":"https://api.github.com/users/forouher/orgs","repos_url":"https://api.github.com/users/forouher/repos","events_url":"https://api.github.com/users/forouher/events{/privacy}","received_events_url":"https://api.github.com/users/forouher/received_events","type":"User","site_admin":false},"repo":{"id":24812875,"name":"seadroid","full_name":"forouher/seadroid","owner":{"login":"forouher","id":676900,"avatar_url":"https://avatars.githubusercontent.com/u/676900?v=3","gravatar_id":"","url":"https://api.github.com/users/forouher","html_url":"https://github.com/forouher","followers_url":"https://api.github.com/users/forouher/followers","following_url":"https://api.github.com/users/forouher/following{/other_user}","gists_url":"https://api.github.com/users/forouher/gists{/gist_id}","starred_url":"https://api.github.com/users/forouher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forouher/subscriptions","organizations_url":"https://api.github.com/users/forouher/orgs","repos_url":"https://api.github.com/users/forouher/repos","events_url":"https://api.github.com/users/forouher/events{/privacy}","received_events_url":"https://api.github.com/users/forouher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/forouher/seadroid","description":"Android client for Seafile","fork":true,"url":"https://api.github.com/repos/forouher/seadroid","forks_url":"https://api.github.com/repos/forouher/seadroid/forks","keys_url":"https://api.github.com/repos/forouher/seadroid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/forouher/seadroid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/forouher/seadroid/teams","hooks_url":"https://api.github.com/repos/forouher/seadroid/hooks","issue_events_url":"https://api.github.com/repos/forouher/seadroid/issues/events{/number}","events_url":"https://api.github.com/repos/forouher/seadroid/events","assignees_url":"https://api.github.com/repos/forouher/seadroid/assignees{/user}","branches_url":"https://api.github.com/repos/forouher/seadroid/branches{/branch}","tags_url":"https://api.github.com/repos/forouher/seadroid/tags","blobs_url":"https://api.github.com/repos/forouher/seadroid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/forouher/seadroid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/forouher/seadroid/git/refs{/sha}","trees_url":"https://api.github.com/repos/forouher/seadroid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/forouher/seadroid/statuses/{sha}","languages_url":"https://api.github.com/repos/forouher/seadroid/languages","stargazers_url":"https://api.github.com/repos/forouher/seadroid/stargazers","contributors_url":"https://api.github.com/repos/forouher/seadroid/contributors","subscribers_url":"https://api.github.com/repos/forouher/seadroid/subscribers","subscription_url":"https://api.github.com/repos/forouher/seadroid/subscription","commits_url":"https://api.github.com/repos/forouher/seadroid/commits{/sha}","git_commits_url":"https://api.github.com/repos/forouher/seadroid/git/commits{/sha}","comments_url":"https://api.github.com/repos/forouher/seadroid/comments{/number}","issue_comment_url":"https://api.github.com/repos/forouher/seadroid/issues/comments/{number}","contents_url":"https://api.github.com/repos/forouher/seadroid/contents/{+path}","compare_url":"https://api.github.com/repos/forouher/seadroid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/forouher/seadroid/merges","archive_url":"https://api.github.com/repos/forouher/seadroid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/forouher/seadroid/downloads","issues_url":"https://api.github.com/repos/forouher/seadroid/issues{/number}","pulls_url":"https://api.github.com/repos/forouher/seadroid/pulls{/number}","milestones_url":"https://api.github.com/repos/forouher/seadroid/milestones{/number}","notifications_url":"https://api.github.com/repos/forouher/seadroid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/forouher/seadroid/labels{/name}","releases_url":"https://api.github.com/repos/forouher/seadroid/releases{/id}","created_at":"2014-10-05T09:58:47Z","updated_at":"2014-09-22T14:35:34Z","pushed_at":"2015-01-03T00:40:01Z","git_url":"git://github.com/forouher/seadroid.git","ssh_url":"git@github.com:forouher/seadroid.git","clone_url":"https://github.com/forouher/seadroid.git","svn_url":"https://github.com/forouher/seadroid","homepage":null,"size":3824,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"haiwen:1.4","ref":"1.4","sha":"b5066343c1583ab5ff30e4d7ff7cb813d9a43b77","user":{"login":"haiwen","id":1948782,"avatar_url":"https://avatars.githubusercontent.com/u/1948782?v=3","gravatar_id":"","url":"https://api.github.com/users/haiwen","html_url":"https://github.com/haiwen","followers_url":"https://api.github.com/users/haiwen/followers","following_url":"https://api.github.com/users/haiwen/following{/other_user}","gists_url":"https://api.github.com/users/haiwen/gists{/gist_id}","starred_url":"https://api.github.com/users/haiwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haiwen/subscriptions","organizations_url":"https://api.github.com/users/haiwen/orgs","repos_url":"https://api.github.com/users/haiwen/repos","events_url":"https://api.github.com/users/haiwen/events{/privacy}","received_events_url":"https://api.github.com/users/haiwen/received_events","type":"Organization","site_admin":false},"repo":{"id":6900541,"name":"seadroid","full_name":"haiwen/seadroid","owner":{"login":"haiwen","id":1948782,"avatar_url":"https://avatars.githubusercontent.com/u/1948782?v=3","gravatar_id":"","url":"https://api.github.com/users/haiwen","html_url":"https://github.com/haiwen","followers_url":"https://api.github.com/users/haiwen/followers","following_url":"https://api.github.com/users/haiwen/following{/other_user}","gists_url":"https://api.github.com/users/haiwen/gists{/gist_id}","starred_url":"https://api.github.com/users/haiwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haiwen/subscriptions","organizations_url":"https://api.github.com/users/haiwen/orgs","repos_url":"https://api.github.com/users/haiwen/repos","events_url":"https://api.github.com/users/haiwen/events{/privacy}","received_events_url":"https://api.github.com/users/haiwen/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/haiwen/seadroid","description":"Android client for Seafile","fork":false,"url":"https://api.github.com/repos/haiwen/seadroid","forks_url":"https://api.github.com/repos/haiwen/seadroid/forks","keys_url":"https://api.github.com/repos/haiwen/seadroid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haiwen/seadroid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haiwen/seadroid/teams","hooks_url":"https://api.github.com/repos/haiwen/seadroid/hooks","issue_events_url":"https://api.github.com/repos/haiwen/seadroid/issues/events{/number}","events_url":"https://api.github.com/repos/haiwen/seadroid/events","assignees_url":"https://api.github.com/repos/haiwen/seadroid/assignees{/user}","branches_url":"https://api.github.com/repos/haiwen/seadroid/branches{/branch}","tags_url":"https://api.github.com/repos/haiwen/seadroid/tags","blobs_url":"https://api.github.com/repos/haiwen/seadroid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haiwen/seadroid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haiwen/seadroid/git/refs{/sha}","trees_url":"https://api.github.com/repos/haiwen/seadroid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haiwen/seadroid/statuses/{sha}","languages_url":"https://api.github.com/repos/haiwen/seadroid/languages","stargazers_url":"https://api.github.com/repos/haiwen/seadroid/stargazers","contributors_url":"https://api.github.com/repos/haiwen/seadroid/contributors","subscribers_url":"https://api.github.com/repos/haiwen/seadroid/subscribers","subscription_url":"https://api.github.com/repos/haiwen/seadroid/subscription","commits_url":"https://api.github.com/repos/haiwen/seadroid/commits{/sha}","git_commits_url":"https://api.github.com/repos/haiwen/seadroid/git/commits{/sha}","comments_url":"https://api.github.com/repos/haiwen/seadroid/comments{/number}","issue_comment_url":"https://api.github.com/repos/haiwen/seadroid/issues/comments/{number}","contents_url":"https://api.github.com/repos/haiwen/seadroid/contents/{+path}","compare_url":"https://api.github.com/repos/haiwen/seadroid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haiwen/seadroid/merges","archive_url":"https://api.github.com/repos/haiwen/seadroid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haiwen/seadroid/downloads","issues_url":"https://api.github.com/repos/haiwen/seadroid/issues{/number}","pulls_url":"https://api.github.com/repos/haiwen/seadroid/pulls{/number}","milestones_url":"https://api.github.com/repos/haiwen/seadroid/milestones{/number}","notifications_url":"https://api.github.com/repos/haiwen/seadroid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haiwen/seadroid/labels{/name}","releases_url":"https://api.github.com/repos/haiwen/seadroid/releases{/id}","created_at":"2012-11-28T10:54:37Z","updated_at":"2014-12-27T19:47:27Z","pushed_at":"2014-12-25T02:21:24Z","git_url":"git://github.com/haiwen/seadroid.git","ssh_url":"git@github.com:haiwen/seadroid.git","clone_url":"https://github.com/haiwen/seadroid.git","svn_url":"https://github.com/haiwen/seadroid","homepage":null,"size":7627,"stargazers_count":118,"watchers_count":118,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":90,"mirror_url":null,"open_issues_count":43,"forks":90,"open_issues":43,"watchers":118,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/haiwen/seadroid/pulls/220"},"html":{"href":"https://github.com/haiwen/seadroid/pull/220"},"issue":{"href":"https://api.github.com/repos/haiwen/seadroid/issues/220"},"comments":{"href":"https://api.github.com/repos/haiwen/seadroid/issues/220/comments"},"review_comments":{"href":"https://api.github.com/repos/haiwen/seadroid/pulls/220/comments"},"review_comment":{"href":"https://api.github.com/repos/haiwen/seadroid/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/haiwen/seadroid/pulls/220/commits"},"statuses":{"href":"https://api.github.com/repos/haiwen/seadroid/statuses/7eb70ba0398c79791e0bd98e3270030992d94908"}}}}