首页 > 解决方案 > jenkins/java 升级后如何解决或解决由于 rsa 密钥大小 2047 导致的 CVS 身份验证问题?

问题描述

这个问题困扰我好几年了!解决这个问题需要改变什么关键?

背景:大小为 2048 的 ssh rsa 密钥可以以前导 1 或 0 开头。前导 0 导致密钥被某些软件视为长度为 2047。这些密钥似乎不符合标准,因此它们不被最新的软件库所接受。

旧的 java 版本和默认加密库用于允许 2047 大小的 rsa 密钥。较新的java没有。"""java.security.InvalidAlgorithmParameterException: DH key size must be multiple of 64, and can only range from 512 to 8192 (inclusive). 具体的key size 2047 is not supported""" 可见。

我们看到的是,当 jenkins 升级时,现在 CVS 访问工作的作业不起作用:-(

如果不重建 jenkins 以使用不同的安全库,是否可以解决这个问题?

尝试将 CVS 用户密钥重新生成为 RSA 大小 4096。没有成功。是关于错误的 CVS 服务器主机密钥还是 CVS 用户密钥?

https://www.ssh.com/ssh/keygen/

ssh-keygen -t rsa -b 4096

错误可以通过使用不同的加密库来解决: DH 密钥大小必须是 64 的倍数,并且只能从 512 到 2048(含)

2047 和 2048 RSA 密钥长度: https ://security.stackexchange.com/questions/90169/rsa-public-key-and-private-key-lengths

DHGEX 在 Java 8 下使用 2048 位密钥失败,但使用 1024 位密钥成功

Building in workspace /var/lib/jenkins/workspace/cvs_status_xxxxx
cvs checkout -P -D 15 Mar 2019 12:30:42 +0000 -d xxxxx xxxxx 
ERROR: CVS Authentication failed: null
org.netbeans.lib.cvsclient.connection.AuthenticationException: SSH connection failed.
    at org.netbeans.lib.cvsclient.connection.SSHConnection.open(SSHConnection.java:141)
    at org.netbeans.lib.cvsclient.Client$1.run(Client.java:374)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.jcraft.jsch.JSchException: Session.connect: java.security.InvalidAlgorithmParameterException: DH key size must be multiple of 64, and can only range from 512 to 8192 (inclusive). The specific key size 2047 is not supported
    at com.jcraft.jsch.Session.connect(Session.java:565)
    at com.jcraft.jsch.Session.connect(Session.java:183)
    at org.netbeans.lib.cvsclient.connection.SSHConnection.open(SSHConnection.java:139)
    ... 2 more
ERROR: Cvs task failed
ERROR: Step ‘Archive the artifacts’ failed: No artifacts are configured for archiving.
You probably forgot to set the file pattern, so please go back to the configuration and specify it.
If you really did mean to archive all the files in the workspace, please specify "**"
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

https://bugs.openjdk.java.net/browse/JDK-8164963 在 RFC 2631 和 FIPS 186-3/4 p 中不能有前导零。JDK 强制执行此操作。 https://www.ietf.org/rfc/rfc2631.txt 它在 RFC 的这一部分中进行了概述:“2.2.1.1. p, q 的生成”

标签: jenkinsjenkins-pluginscvsssh-keys

解决方案


推荐阅读