系统导入:导入系统导出加密问题

斯科特•莫舍
2023-01-22 11:06

导入加密的系统导出遇到关键问题

Artifactory有一些密钥可以加密不同的配置文件。导致导入/导出出现问题的是artifact .key。可以通过以下两个REST API调用激活和禁用此特定密钥的加密。

//www.si-fil.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-ActivateArtifactoryKeyEncryption

//www.si-fil.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-DeactivateArtifactoryKeyEncryption

运行导入时出现的问题

如果我们对加密环境进行系统导出,那么在导入过程中很可能会遇到问题。这artifactory。Key用于加密导出中包含的artifact .config.xml中的密码。当我们运行其中一个导出时,我们在日志中看到以下错误。
2022-08-24T22:56:39.247Z [jfrt] [ERROR] [1527aaa13675d151] [c.]CentralConfigServiceImpl:961] [http-nio-8081-exec-2] - Failed to reload configuration: javax.crypt . badpaddingexception: Given final block未正确填充。如果在解密过程中使用了错误的密钥,就会出现这样的问题。
2022-08-24T22:56:39.247Z [jfrt] [ERROR] [1527aaa13675d151]ExecutionUtils:190] [http-nio-8081-exec-2] - Last retry failed: failed to reload configuration: javax.crypt . badpaddingexception: Given final block not proper padding。如果在解密过程中使用了坏的密钥,就会出现这样的问题。不再尝试
2022-08-24T22:56:39.249Z [jfrt] [ERROR] [1527aaa13675d151] [ifactoryApplicationContext:728] [http-nio-8081-exec-2] - Failed system import: Could not merge and save new descriptor [org.www.si-fil.common.ExecutionFailed: Last retry Failed: Failed to reload configuration: javax.crypt . badpaddingexception: Given final block未正确填充。如果在解密过程中使用了坏的密钥,就会出现这样的问题。不再尝试

这将导致导入失败。

解决方案/解决方案

要解决这个问题,我们可以实现两个选项。第一种方法是在运行导出之前运行上面提到的解密API。工作流将运行API请求(对成功解密的响应将是“DONE”)。然后,我们将运行System Export,将此导出迁移到新服务器,运行System Import,然后在成功导入后通过运行加密API完成导入。这将产生一个新的工艺品。此已迁移实例的键。

第二种选择(如果没有解密选项)是手动更新artifact .config.xml,或者用纯文本替换加密的密码,或者从这个config.xml文件中删除整个存储库配置。如果我们确实完全删除了这个存储库,那么我们需要在导入之后重新添加这个存储库。
为了更深入地了解这个手动过程,我们要查找的密码可以是远程存储库,需要用户/密码或令牌来通过远程注册中心进行身份验证。这可以是另一个Artifactory实例或一些外部注册表。下面是一个存储库的配置示例:

< remoteRepository >
<键> test-remote关键> < /
<类型> npm > < /类型
(本地文件缓存)
<笔记> < /笔记>
< includesPattern > * * / * < / includesPattern >
< excludesPattern > < / excludesPattern >
< repoLayoutRef > npm-default < / repoLayoutRef >
V2 < dockerApiVersion > < / dockerApiVersion >
........................................
........................................
真正< blockMismatchingMimeTypes > < / blockMismatchingMimeTypes >
< mismatchingMimeTypesOverrideList > < / mismatchingMimeTypesOverrideList >
假< / bypassHeadRequests < bypassHeadRequests > >
<用户名>管理> < /用户名
<密码>JE2fRswdAyuhgd2vVrevMgfoCzwHTpLu2WVP9EaZ2wJhYy87cU< /密码>
假< / allowAnyHostAuth < allowAnyHostAuth > >
15000年< socketTimeoutMillis > < / socketTimeoutMillis >
假< / enableCookieManagement < enableCookieManagement > >
假< / enableTokenAuthentication < enableTokenAuthentication > >
假< / disableProxy < disableProxy > >
假< / propagateQueryParams < propagateQueryParams > >
假< / disableUrlNormalization < disableUrlNormalization > >
< / remoteRepository >

我们可以在配置文件中搜索这个“JE”,因为这将是我们需要更新的加密密码的前两个字符。在更新或删除所有这些加密密码之后,我们应该能够成功地运行系统导入。