负载均衡器SSL卸载管理

时间:2016-09-27 09:09:38

标签: ibm-cloud-infrastructure

我想实现负载均衡器的ssl offload 如何ssl启用/禁用和保存更改的安全传输协议和密码信息 我的开发语言是java

load balancer ssl offload tab ui

1 个答案:

答案 0 :(得分:0)

您是否尝试编辑负载均衡器?

import java.util.ArrayList;
import java.util.List;

import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.network.application.delivery.controller.loadbalancer.*;
import com.softlayer.api.service.network.application.delivery.controller.loadbalancer.virtualipaddress.SecureTransportCipher;
import com.softlayer.api.service.network.application.delivery.controller.loadbalancer.virtualipaddress.SecureTransportProtocol;

public class LoadBalancerSSL {

    public static void main(String[] args) {
        String user = "set me";
        String apikey = "set me";
        Long vIId = 124185L; //ID of the load blancer


        ApiClient client = new RestApiClient().withCredentials(user, apikey);
        VirtualIpAddress.Service vIService = VirtualIpAddress.service(client, vIId);

        VirtualIpAddress edit = vIService.getObject();

        edit.setSecurityCertificateId(64507L);

        List<SecureTransportCipher> ciphers = new ArrayList<SecureTransportCipher>();

        SecureTransportCipher sha128 = new SecureTransportCipher();
        sha128.setKeyName("AES128-SHAkeyName");
        sha128.setVirtualIpAddressId(vIId);

        SecureTransportCipher sha256 = new SecureTransportCipher();
        sha256.setKeyName("AES256-SHA");
        sha256.setVirtualIpAddressId(vIId);

        SecureTransportCipher desCbc = new SecureTransportCipher();
        desCbc.setKeyName("DES-CBC-SHA");
        desCbc.setVirtualIpAddressId(vIId);

        SecureTransportCipher desCbc3 = new SecureTransportCipher();
        desCbc3.setKeyName("DES-CBC3-SHA");
        desCbc3.setVirtualIpAddressId(vIId);

        SecureTransportCipher rc4md5 = new SecureTransportCipher();
        rc4md5.setKeyName("RC4-MD5");
        rc4md5.setVirtualIpAddressId(vIId);

        SecureTransportCipher rc4sha = new SecureTransportCipher();
        rc4sha.setKeyName("RC4-SHA");
        rc4sha.setVirtualIpAddressId(vIId);

        SecureTransportCipher aes128 = new SecureTransportCipher();
        aes128.setKeyName("AES128-SHA256");
        aes128.setVirtualIpAddressId(vIId);

        SecureTransportCipher aes256 = new SecureTransportCipher();
        aes256.setKeyName("AES256-SHA256");
        aes256.setVirtualIpAddressId(vIId);

        //ciphers.add(sha128);
        ciphers.add(sha256);
        //ciphers.add(desCbc);
        ciphers.add(desCbc3);
        ciphers.add(rc4md5);
        ciphers.add(rc4sha);
        //ciphers.add(aes128);
        //ciphers.add(aes256);

        edit.getSecureTransportCiphers().clear();
        edit.getSecureTransportCiphers().addAll(ciphers);

        List<SecureTransportProtocol> protocols = new ArrayList<SecureTransportProtocol>();

        SecureTransportProtocol tlsv1 = new SecureTransportProtocol();
        tlsv1.setKeyName("TLSV1");
        tlsv1.setVirtualIpAddressId(vIId);

        SecureTransportProtocol tlsv2 = new SecureTransportProtocol();
        tlsv2.setKeyName("TLSV12");
        tlsv2.setVirtualIpAddressId(vIId);

        protocols.add(tlsv1);
        protocols.add(tlsv2);

        edit.getSecureTransportProtocols().clear();
        edit.getSecureTransportProtocols().addAll(protocols);



        System.out.println(vIService.editObject(edit));

        // Disable SSL
        // vIService.stopSsl();

        // Enable SSL
        //vIService.startSsl();

    }

}