Skip to content

Commit 5519095

Browse files
committed
CLOUDSTACK-8070: during 4.3.1 to 4.3.2 upgrade encrypt config that are hidden
In case there is an encryption key/password is provided the value, specifically for router.ram.size will be encrypted otherwise it will remain plain text. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 485c76a commit 5519095

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎engine/schema/src/com/cloud/upgrade/dao/Upgrade431to432.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.cloud.upgrade.dao;
1919

2020
import java.io.File;
21+
import java.io.UnsupportedEncodingException;
2122
import java.sql.Connection;
2223
import java.sql.PreparedStatement;
2324
import java.sql.ResultSet;
@@ -28,6 +29,7 @@
2829
import java.util.Map;
2930
import java.util.Set;
3031

32+
import com.cloud.utils.crypt.DBEncryptionUtil;
3133
import com.cloud.utils.exception.CloudRuntimeException;
3234

3335
import org.apache.log4j.Logger;
@@ -65,10 +67,14 @@ public void performDataMigration(Connection conn) {
6567
private void updateMaxRouterSizeConfig(Connection conn) {
6668
PreparedStatement updatePstmt = null;
6769
try {
68-
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value='256' WHERE name='router.ram.size'");
70+
String encryptedValue = DBEncryptionUtil.encrypt("256");
71+
updatePstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value=? WHERE name='router.ram.size' AND category = 'Hidden'");
72+
updatePstmt.setBytes(1, encryptedValue.getBytes("UTF-8"));
6973
updatePstmt.executeUpdate();
7074
} catch (SQLException e) {
7175
throw new CloudRuntimeException("Unable to upgrade max ram size of router in config.", e);
76+
} catch (UnsupportedEncodingException e) {
77+
throw new CloudRuntimeException("Unable encrypt configuration values ", e);
7278
} finally {
7379
try {
7480
if (updatePstmt != null) {

0 commit comments

Comments
 (0)