2017-02-18 37 views
1

我配置WSO2身份服务器新的CA证书。 我用grep和替代wso2carbon.jks和我的新.jks取代。错误而对解密档案BPEL密码embeded_bps

我想我错了取代了一些我不应该拥有的地方。 有人可以告诉我哪个地方可能会导致异常吗? 还是因为其他问题?

org.wso2.carbon.identity.workflow.impl.WorkflowImplException: Error while decrypting the password for BPEL Profile embeded_bps 
     at org.wso2.carbon.identity.workflow.impl.dao.BPSProfileDAO.getBPSProfile(BPSProfileDAO.java:158) 
     at org.wso2.carbon.identity.workflow.impl.WorkflowImplServiceImpl.getBPSProfile(WorkflowImplServiceImpl.j 

    at java.lang.Thread.run(Thread.java:745) 
Caused by: org.wso2.carbon.core.util.CryptoException: errorDuringDecryption 
     at org.wso2.carbon.core.util.CryptoUtil.decrypt(CryptoUtil.java:186) 
     at org.wso2.carbon.core.util.CryptoUtil.base64DecodeAndDecrypt(CryptoUtil.java:200) 
     at org.wso2.carbon.identity.workflow.impl.dao.BPSProfileDAO.decryptPassword(BPSProfileDAO.java:264) 
     at org.wso2.carbon.identity.workflow.impl.dao.BPSProfileDAO.getBPSProfile(BPSProfileDAO.java:156) 
     ... 108 more 
Caused by: java.security.InvalidKeyException: unknown key type passed to RSA 
     at org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineInit(Unknown Source) 
     at org.bouncycastle.jcajce.provider.asymmetric.rsa.CipherSpi.engineInit(Unknown Source) 
     at javax.crypto.Cipher.init(Cipher.java:1065) 
     at javax.crypto.Cipher.init(Cipher.java:1009) 
     at org.wso2.carbon.core.util.CryptoUtil.decrypt(CryptoUtil.java:181) 

... 111多个

+0

您是否启用了BPS AnalyticsServerProfile? – Bee

+0

我没有做任何特别的事情来启用它.. 我正在使用预先打包的版本......我刚刚安装了我的新证书 – Jocket

+0

您是否找到了解决方案?使用别名wso2carbon更新ssl cert后,我有同样的事情。 wso2文件明确表示这很好,但是当你改变它时,一切都停止工作:( –

回答

0

你需要找到该表:WF_BPS_PROFILE这个colums: HOST_URL_MANAGER,HOST_URL_WORKER,用户名,密码

我认为,在密码值与encripted wso2cabon.jks中的上一个键值,因此您需要用新值替换该值。

欲了解更多信息,你可以找到类BPSProfileDAO.java

而且该方法的定义:

/** 
    * Retrieve details of a BPS profile 
    * 
    * @param profileName  Name of profile to retrieve 
    * @param tenantId  Id of tenant domain 
    * @param isWithPasswords Whether password to be retrieved or not 
    * @return 
    * @throws WorkflowImplException 
    */ 
    public BPSProfile getBPSProfile(String profileName, int tenantId, boolean isWithPasswords) throws 
                           WorkflowImplException 
{ 

     BPSProfile bpsProfileDTO = null; 
     Connection connection = IdentityDatabaseUtil.getDBConnection(); 
     PreparedStatement prepStmt = null; 
     ResultSet rs; 
     String query = SQLConstants.GET_BPS_PROFILE_FOR_TENANT_QUERY; 

     try { 
      prepStmt = connection.prepareStatement(query); 
      prepStmt.setString(1, profileName); 
      prepStmt.setInt(2, tenantId); 
      rs = prepStmt.executeQuery(); 

      if (rs.next()) { 
       String managerHostName = rs.getString(SQLConstants.HOST_URL_MANAGER_COLUMN); 
       String workerHostName = rs.getString(SQLConstants.HOST_URL_WORKER_COLUMN); 
       String user = rs.getString(SQLConstants.USERNAME_COLUMN); 
       bpsProfileDTO = new BPSProfile(); 
       bpsProfileDTO.setProfileName(profileName); 
       bpsProfileDTO.setManagerHostURL(managerHostName); 
       bpsProfileDTO.setWorkerHostURL(workerHostName); 
       bpsProfileDTO.setUsername(user); 

       if (isWithPasswords) { 
        String password = rs.getString(SQLConstants.PASSWORD_COLUMN); 
        try { 
         bpsProfileDTO.setPassword(decryptPassword(password)); 
        } catch (CryptoException | UnsupportedEncodingException e) { 
         throw new WorkflowImplException("Error while decrypting the password for BPEL Profile " 
           + profileName, e); 
        } 
       } 
      } 
     } catch (SQLException e) { 
      throw new WorkflowImplException("Error when executing the sql.", e); 
     } finally { 
      IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); 
     } 
     return bpsProfileDTO; 
    } 

查询:

public static final String GET_BPS_PROFILE_FOR_TENANT_QUERY = "SELECT HOST_URL_MANAGER, HOST_URL_WORKER, " + 
     "USERNAME,PASSWORD FROM WF_BPS_PROFILE WHERE PROFILE_NAME = ? AND " + 
     "TENANT_ID = ? "; 

一些UTIL方法:

private String encryptPassword(char[] passwordValue) throws CryptoException { 

    CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); 
    return cryptoUtil.encryptAndBase64Encode(toBytes(passwordValue)); 
} 



private char[] decryptPassword(String passwordValue) throws UnsupportedEncodingException, CryptoException { 

    CryptoUtil cryptoUtil = CryptoUtil.getDefaultCryptoUtil(); 
    byte[] decryptedPasswordBytes = cryptoUtil.base64DecodeAndDecrypt(passwordValue); 
    return (new String(decryptedPasswordBytes, WFImplConstant.DEFAULT_CHARSET)).toCharArray(); 

} 

/** 
* Convert a char array into a byte array 
* 
* @param chars 
* @return 
*/ 
private byte[] toBytes(char[] chars) { 
    CharBuffer charBuffer = CharBuffer.wrap(chars); 
    ByteBuffer byteBuffer = Charset.forName(WFImplConstant.DEFAULT_CHARSET).encode(charBuffer); 
    byte[] bytes = Arrays.copyOfRange(byteBuffer.array(), 
      byteBuffer.position(), byteBuffer.limit()); 
    Arrays.fill(charBuffer.array(), '\u0000'); 
    Arrays.fill(byteBuffer.array(), (byte) 0); 
    return bytes; 
} 
+0

更新配置文件,尝试清除表并重新启动此错误应该消失。附带WSO2的。在第一次启动时,我们加密的默认密码是空字符串,并把它在数据库中。 – farasath

0

一般来说,当服务器已经保存了某些数据(例如,密码)使用默认密钥库中的公钥加密。所以当你改变密钥库时,它不能再解密这些数据。所以理想情况下,您应该将密钥库更改为生产部署中的第一件事。

在你的情况,你可以尝试下<ServerProfile>改变<Credential>相应的(也许设置securePassword="false"现在)。

阅读thisthis了解详情。

+0

哪个文件有这个属性? 我不能在所有找到该物业嵌入式基点 – Jocket