带有Socks5代理的Java SSLSocket

时间:2018-02-17 14:41:51

标签: java sockets ssl socks

如何在socks5代理中使用SSLSocket?我使用带代理的普通套接字作为底层。

此代码不起作用:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        applicationId "com.example.murarilal.atry"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding{
    enabled true
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '25.3.1'
                }
            }
        }
    }
    //compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
    compile 'com.android.support:design:26.0.0-alpha1'
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:support-v4:26.0.0-alpha1'
    compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
    compile 'com.android.support:cardview-v7:26.0.0-alpha1'
    compile 'de.hdodenhof:circleimageview:2.2.0'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
}

此代码抛出异常:

线程“main”中的异常javax.net.ssl.SSLException:无法识别的SSL消息,明文连接?

没有SSL,代码可以正常工作。

1 个答案:

答案 0 :(得分:1)

您正在将SSL与明文端口进行通信。

正如错误消息所示。

修复端口或不使用SSL。