SSL證書
SSL 證書允許您在本機代理模式下使用網頁解鎖器時建立端到端加密連接。
如果您只是進行初步測試,您也可以先不使用 SSL 證書,稍後再使用它。
使用 SSL 證書非常簡單。您可以下載它,然後選擇如何在您的環境中使用它。
下載 SSL 證書
單擊此鏈接將文件「下載」到您的硬盤,並解壓文件。
在代碼中使用 SSL 證書
如果您編寫抓取代碼,大多數情況下,您不需要在您的環境中安裝 SSL 證書。只需在您的代碼中加載 SSL 證書即可。
curl -i --proxy unlocker.lunaproxy.net:13333 --proxy-user [username]:[password] --cacert <PATH TO CA.CRT>
-k "[target URL]"
您可以參考儀表板中的 LunaProxy示例代碼示例來了解確切的語法。
安裝 SSL 證書
在某些情況下,例如當使用某些不允許從硬盤加載證書的第三方工具時,您仍然需要在計算機上安裝 SSL 證書。
安裝說明
這需要 2 分鐘 - 只需按照以下說明操作即可:
該SSL證書適用於:Windows
1
單擊此鏈接將文件「下載」到您的硬盤,並解壓文件。
https://download.lunaproxy.com/file/pc/LunaProxy_SSL_Certificate.zip
2
雙擊 Autoinstall 文件
3
安裝成功後您將能夠連接到所需的 LunaProxy產品(網頁解鎖器)
如何忽略 SSL 錯誤?
在某些情況下,您需要安裝我們的證書或忽略 SSL 錯誤才能訪問特定產品或功能。如果您不想安裝我們的證書,您可以忽略 SSL 錯誤。查看以下針對不同編程語言的代碼片段,突出顯示的部分是需要添加到您的代碼中以忽略 SSL 錯誤的內容。
代碼示例
# Add -k to ignore ssl errors
curl -i --proxy unlocker.lunaproxy.net:13333 --proxy-user [username]:[password]
-k "http://myip.lunaproxy.io"
#!/usr/bin/env node
/*This sample code assumes the request-promise package is installed. If it is not installed run: "npm install request-promise"*/
require('request-promise')({
url: 'http://myip.lunaproxy.io',
proxy: 'http://<username>:<password>@unlocker.lunaproxy.net:13333',
// Make sure you set reject rejectUnauthorized to false
rejectUnauthorized: false,
})
.then(function(data){ console.log(data); },
function(err){ console.error(err); });
#!/usr/bin/env python
print('If you get error "ImportError: No module named \'six\'" install six:\n'+\
'$ sudo pip install six');
import sys
# Make sure you add these two line to ignore ssl error
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
if sys.version_info[0]==2:
import six
from six.moves.urllib import request
opener = request.build_opener(
request.ProxyHandler(
{'http': 'http://<username>:<password>@unlocker.lunaproxy.net:13333',
'https': 'http://<username>:<password>@unlocker.lunaproxy.net:13333'}))
print(opener.open('http://myip.lunaproxy.io').read())
if sys.version_info[0]==3:
import urllib.request
opener = urllib.request.build_opener(
urllib.request.ProxyHandler(
{'http': 'http://<username>:<password>@unlocker.lunaproxy.net:13333',
'https': 'http://<username>:<password>@unlocker.lunaproxy.net:13333'}))
print(opener.open('http://myip.lunaproxy.io').read())
using System;
using System.Net;
class Example
{
static void Main()
{
// Make sure you add this line to ignore ssl error
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
var client = new WebClient();
client.Proxy = new WebProxy("unlocker.lunaproxy.net:13333");
client.Proxy.Credentials = new NetworkCredential("<username>", "<password>");
Console.WriteLine(client.DownloadString("http://myip.lunaproxy.io"));
}
}
#!/usr/bin/ruby
require 'uri'
require 'net/http'
require 'net/https'
uri = URI.parse('http://myip.lunaproxy.io')
proxy = Net::HTTP::Proxy('unlocker.lunaproxy.net', 13333, '<username>', '<password>')
req = Net::HTTP::Get.new(uri)
# Make sure you add verify_mode => OpenSSL::SSL::VERIFY_NONE
result = proxy.start(uri.host,uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
http.request(req)
send
puts result.body
package example;
import org.apache.http.HttpHost;
import org.apache.http.client.fluent.*;
public class Example {
public static void main(String[] args) throws Exception {
HttpHost proxy = new HttpHost("unlocker.lunaproxy.net", 13333);
String res = Executor.newInstance()
.auth(proxy, "<username>", "<password>")
.execute(Request.Get("http://myip.lunaproxy.io").viaProxy(proxy))
.returnContent().asString();
System.out.println(res);
}
}
/*In the above example, we are not explicitly ignoring SSL
I will share with you a short code I wrote that does ignore SSL using JAVA (was taken from cloud proxy manager examples) */
import java.io.*;
import java.net.*;
import java.security.cert.X509Certificate;
import javax.net.ssl.*;
import java.util.Base64;
public class Example {
public static void main(String[] args) throws Exception {
// Disable restricted headers for proxy authentication
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
// Set up a TrustManager that does not validate certificate chains
SSLContext sc = SSLContext.getInstance("SSL");
TrustManager trust_manager = new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
};
TrustManager[] trust_all = new TrustManager[] { trust_manager };
sc.init(null, trust_all, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
// Set up the proxy and open a connection
URL url = new URL("http://myip.lunaproxy.io");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("unlocker.lunaproxy.net", 13333));
URLConnection yc = url.openConnection(proxy);
// Set default Authenticator for proxy authentication
Authenticator.setDefault(new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("<username>", "<password>".toCharArray());
}
});
// Read and print the response from the server
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
Imports System.Net
Module Module1
Sub Main()
' Make sure you add this line to ignore ssl error
ServicePointManager.ServerCertificateValidationCallback = Function(se, cert, chain, sslerror) True
Dim Client As New WebClient
Client.Proxy = New WebProxy("http://unlocker.lunaproxy.net:13333")
Client.Proxy.Credentials = New NetworkCredential("<username>", "<password>")
Console.WriteLine(Client.DownloadString("http://myip.lunaproxy.io"))
End Sub
End Module
<?php
$curl = curl_init('http://myip.lunaproxy.io');
curl_setopt($curl, CURLOPT_PROXY, 'http://unlocker.lunaproxy.net:13333');
curl_setopt($curl, CURLOPT_PROXYUSERPWD, '<username>:<password>');
// Make sure you add this line to ignore ssl error
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_exec($curl);
?>
#!/usr/bin/perl
use LWP::UserAgent;
# Make sure you add this line to ignore ssl error
use IO::Socket::SSL qw( SSL_VERIFY_NONE );
my $agent = LWP::UserAgent->new();
$agent->proxy(['http', 'https'], "http://<username>:<password>@unlocker.lunaproxy.net:13333");
$agent->ssl_opts(verify_hostname => 0, SSL_verify_mode => SSL_VERIFY_NONE);
print $agent->get('http://myip.lunaproxy.io')->content();
Last updated
Was this helpful?