|
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; |
| 21 | +import java.net.URLDecoder; |
20 | 22 | import java.security.NoSuchAlgorithmException; |
21 | 23 | import java.security.SecureRandom; |
22 | 24 | import java.util.ArrayList; |
@@ -3301,18 +3303,32 @@ public String uploadCertificate(UploadCustomCertificateCmd cmd) { |
3301 | 3303 | } |
3302 | 3304 | } |
3303 | 3305 |
|
3304 | | - if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix())) { |
| 3306 | + String certificate = cmd.getCertificate(); |
| 3307 | + String key = cmd.getPrivateKey(); |
| 3308 | + try { |
| 3309 | + if (certificate != null) |
| 3310 | + certificate = URLDecoder.decode(certificate, "UTF-8"); |
| 3311 | + if (key != null) |
| 3312 | + key = URLDecoder.decode(key, "UTF-8"); |
| 3313 | + } catch (UnsupportedEncodingException e) { |
| 3314 | + } finally { |
| 3315 | + } |
| 3316 | + |
| 3317 | + if (cmd.getPrivateKey() != null && !_ksMgr.validateCertificate(certificate, key, cmd.getDomainSuffix())) { |
3305 | 3318 | throw new InvalidParameterValueException("Failed to pass certificate validation check"); |
3306 | 3319 | } |
3307 | 3320 |
|
3308 | 3321 | if (cmd.getPrivateKey() != null) { |
3309 | | - _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, cmd.getCertificate(), cmd.getPrivateKey(), cmd.getDomainSuffix()); |
| 3322 | + _ksMgr.saveCertificate(ConsoleProxyManager.CERTIFICATE_NAME, certificate, key, cmd.getDomainSuffix()); |
3310 | 3323 | } else { |
3311 | | - _ksMgr.saveCertificate(cmd.getAlias(), cmd.getCertificate(), cmd.getCertIndex(), cmd.getDomainSuffix()); |
| 3324 | + _ksMgr.saveCertificate(cmd.getAlias(), certificate, cmd.getCertIndex(), cmd.getDomainSuffix()); |
3312 | 3325 | } |
3313 | 3326 |
|
3314 | 3327 | _consoleProxyMgr.setManagementState(ConsoleProxyManagementState.ResetSuspending); |
3315 | | - 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"; |
| 3328 | + List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates(null, State.Running, State.Migrating, State.Starting); |
| 3329 | + for (SecondaryStorageVmVO ssVmVm : alreadyRunning) |
| 3330 | + _secStorageVmMgr.rebootSecStorageVm(ssVmVm.getId()); |
| 3331 | + 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"; |
3316 | 3332 | } |
3317 | 3333 |
|
3318 | 3334 | @Override |
|
0 commit comments