跳转到主要内容
您可以在没有 SSL 证书的情况下使用 Bright Data 产品:
  1. 使用 Bright Data Proxy API。阅读更多内容: API 与原生访问
  2. 通过我们的 KYC 验证流程 获取账户验证
使用 SSL 证书可以在 原生代理模式下,与 住宅代理Web Unlocker APISERP API 建立端到端加密连接。 如果您只是进行初步测试,也可以不安装 SSL 证书,稍后再使用。 使用 SSL 证书非常简单。下载证书,然后根据使用环境选择相应方式加载即可。

下载 SSL 证书

Bright Data 推出了新的 SSL 证书,可用于代理端口:33335
  1. 右键点击链接,将文件“另存为”到本地。
  2. 解压文件并选择要使用的证书。大多数用户——尤其是新用户——应使用新版 SSL 证书。

Bright Data 新版 SSL 证书

Bright Data 新版 SSL 证书即将支持浏览器扩展。如果您正在使用浏览器扩展,请暂时不要升级到新证书。
Bright Data 现在使用更新后的 SSL 证书,有效期至 2034 年 9 月。使用此证书时,必须将原生代理端口设置为 33335,这是用于新证书加密流量的端口。 如果您仍在使用旧版 SSL 证书,请注意它已被弃用,将于 2026 年 9 月到期,且使用端口 22225。为了确保稳定安全的使用体验,请切换到新版证书与端口 33335。更多信息请参阅:FAQ:该使用端口 22225 还是 33335?

在代码中使用 SSL 证书

如果您编写爬虫代码,在大多数情况下无需在系统中安装证书。只需在代码中加载证书即可。例如,CURL:
curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<account-id>-zone-<zone-name>:<zone-password> --cacert <PATH TO CA.CRT> "https://geo.brdtest.com/mygeo.json"
您可以参考 Bright Data 控制台中的示例代码查看具体语法。

安装 SSL 证书

在某些情况下(例如某些无法从本地加载证书的第三方工具),仍需要在您的计算机上安装证书。

我应该将证书安装在哪里?

SSL 证书需要安装在运行实际爬虫代码或应用程序的主机上 大多数情况下,这是您的个人电脑;但如果您在云服务器上运行代码,则必须将证书安装到该服务器上。

安装步骤

只需 2 分钟 — 按以下步骤操作即可:
  • 如果还没有下载,请右键点击链接,将文件“另存为”到本地。
  • 双击 ca.crt 文件
  • 按照 Windows 的提示安装证书
  • 重启电脑
  • 重启后,您就可以连接所需的 Bright Data 产品(住宅代理、Web Unlocker API 或 SERP API)

如何忽略 SSL 错误?

在某些情况下,你需要安装我们的证书或忽略 SSL 错误,才能访问特定的产品或功能。如果你不想安装我们的证书,你可以选择忽略 SSL 错误。请查看以下不同编程语言的代码示例,高亮的部分就是你需要添加到代码中以忽略 SSL 错误的内容。
# Add -k to ignore ssl errors
curl --proxy brd.superproxy.io:33335 --proxy-user brd-customer-<customer_id>-zone-<zone_name>:<zone_password> -k "http://brdtest.com/myip.json"
#!/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://brdtest.com/myip.json',
    proxy: 'http://brd-customer-<customer_id>-zone-<zone_name>:<zone_password>@brd.superproxy.io:33335',

    // 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://brd-customer-<customer_id>-zone-<zone_name>:<zone_password>@brd.superproxy.io:33335',
            'https': 'http://brd-customer-<customer_id>-zone-<zone_name>:<zone_password>@brd.superproxy.io:33335'}))
    print(opener.open('http://brdtest.com/myip.json').read())

if sys.version_info[0]==3:
    import urllib.request
    opener = urllib.request.build_opener(
        urllib.request.ProxyHandler(
            {'http': 'http://brd-customer-<customer_id>-zone-<zone_name>:<zone_password>@brd.superproxy.io:33335',
            'https': 'http://brd-customer-<customer_id>-zone-<zone_name>:<zone_password>@brd.superproxy.io:33335'}))
    print(opener.open('http://brdtest.com/myip.json').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("brd.superproxy.io:33335");
        client.Proxy.Credentials = new NetworkCredential("brd-customer-<customer_id>-zone-<zone_name>", "<zone_password>");
        Console.WriteLine(client.DownloadString("http://brdtest.com/myip.json"));
    }
}
#!/usr/bin/ruby

require 'uri'
require 'net/http'
require 'net/https'

uri = URI.parse('http://brdtest.com/myip.json')
proxy = Net::HTTP::Proxy('brd.superproxy.io', 33335, 'brd-customer-<customer_id>-zone-<zone_name>', '<zone_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("brd.superproxy.io", 33335);
        String res = Executor.newInstance()
            .auth(proxy, "brd-customer-<customer_id>-zone-<zone_name>", "<zone_password>")
            .execute(Request.Get("http://brdtest.com/myip.json").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("https://geo.brdtest.com/mygeo.json");
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("brd.superproxy.io", 33335));
        URLConnection yc = url.openConnection(proxy);

        // Set default Authenticator for proxy authentication
        Authenticator.setDefault(new Authenticator() {
            @Override
            public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("brd-customer-<customer_id>-zone-<zone_name>", "<zone_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://brd.superproxy.io:33335")
        Client.Proxy.Credentials = New NetworkCredential("brd-customer-<customer_id>-zone-<zone_name>", "<zone_password>")
        Console.WriteLine(Client.DownloadString("http://brdtest.com/myip.json"))
    End Sub
End Module
<?php
$curl = curl_init('http://brdtest.com/myip.json');
curl_setopt($curl, CURLOPT_PROXY, 'http://brd.superproxy.io:33335');
curl_setopt($curl, CURLOPT_PROXYUSERPWD, 'brd-customer-<customer_id>-zone-<zone_name>:<zone_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://brd-customer-<customer_id>-zone-<zone_name>:<zone_password>\@brd.superproxy.io:33335");
$agent->ssl_opts(verify_hostname => 0, SSL_verify_mode => SSL_VERIFY_NONE);
print $agent->get('http://brdtest.com/myip.json')->content();

Bright Data Proxy Manager SSL 分析

某些功能要求 Proxy Manager 访问 HTTPS 流量。你可以在代理端口的配置页面启用 SSL Analyzing(SSL 分析) 来实现。 一旦你允许 Proxy Manager 终止 SSL,你还需要信任 Bright Data 证书颁发机构(CA) 在底层,Proxy Manager 会与目标站点建立一个安全加密的 HTTPS 连接,解密流量以记录请求并根据你的设置执行规则,然后再以加密的 HTTPS 连接将响应返回给你的客户端,使用我们的 CA 所签署的证书。