|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.server; |
18 | 18 |
|
| 19 | +import java.io.UnsupportedEncodingException; |
19 | 20 | import java.lang.reflect.Field; |
20 | 21 | import java.net.Inet6Address; |
21 | 22 | import java.net.InetAddress; |
22 | 23 | import java.net.URI; |
23 | 24 | import java.net.URISyntaxException; |
24 | 25 | import java.net.UnknownHostException; |
| 26 | +import java.net.URLDecoder; |
25 | 27 | import java.security.NoSuchAlgorithmException; |
26 | 28 | import java.security.SecureRandom; |
27 | 29 | import java.util.ArrayList; |
@@ -2808,18 +2810,32 @@ public String uploadCertificate(UploadCustomCertificateCmd cmd) { |
2808 | 2810 | } |
2809 | 2811 | } |
2810 | 2812 |
|
2811 | | - if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix())) { |
| 2813 | + String certificate = cmd.getCertificate(); |
| 2814 | + String key = cmd.getPrivateKey(); |
| 2815 | + try { |
| 2816 | + if (certificate != null) |
| 2817 | + certificate = URLDecoder.decode(certificate, "UTF-8"); |
| 2818 | + if (key != null) |
| 2819 | + key = URLDecoder.decode(key, "UTF-8"); |
| 2820 | + } catch (UnsupportedEncodingException e) { |
| 2821 | + } finally { |
| 2822 | + } |
| 2823 | + |
| 2824 | + if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(certificate, key, cmd.getDomainSuffix())) { |
2812 | 2825 | throw new InvalidParameterValueException("Failed to pass certificate validation check"); |
2813 | 2826 | } |
2814 | 2827 |
|
2815 | 2828 | if (cmd.getPrivateKey() != null) { |
2816 | | - _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix()); |
| 2829 | + _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, certificate, key, cmd.getDomainSuffix()); |
2817 | 2830 | } else { |
2818 | | - _ksMgr.saveCertificate(cmd.getAlias(), cmd.getCertificate(), cmd.getCertIndex(), cmd.getDomainSuffix()); |
| 2831 | + _ksMgr.saveCertificate(cmd.getAlias(), certificate, cmd.getCertIndex(), cmd.getDomainSuffix()); |
2819 | 2832 | } |
2820 | 2833 |
|
2821 | 2834 | _consoleProxyMgr.setManagementState(ConsoleProxyManagementState.ResetSuspending); |
2822 | | - return "Certificate has been updated, we will stop all running console proxy VMs to propagate the new certificate, please give a few minutes for console access service to be up again"; |
| 2835 | + List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates(null, State.Running, State.Migrating, State.Starting); |
| 2836 | + for (SecondaryStorageVmVO ssVmVm : alreadyRunning) |
| 2837 | + _secStorageVmMgr.rebootSecStorageVm(ssVmVm.getId()); |
| 2838 | + return "Certificate has been updated, we will stop all running console proxy VMs and secondary storage VMs to propagate the new certificate, please give a few minutes for console access service to be up again"; |
2823 | 2839 | } |
2824 | 2840 |
|
2825 | 2841 | @Override |
|
0 commit comments