You get this error because you are reading a PKCS#8 key file, but your file has a PKCS#1 format (PKCS#1 has the BEGIN RSA PRIVATE KEY
header while PKCS#8 has the BEGIN PRIVATE KEY
header).
In order to read both PKCS#1 and PKCS#8 PEM files, I use the source code of Apache JMeter's org.apache.jmeter.protocol.oauth.sampler.PrivateKeyReader
:
PrivateKey pk = (new PrivateKeyReader("/path/to/myfile.der")).getPrivateKey();
Alternately you can conver your mykey.pem to DER format and use your existing code. Following is the openssl command to do that
//generate PKCS#1 key
openssl genrsa -out mykey.pem 1024
//generate public key
openssl rsa -in mykey.pem -pubout > mykey.pub
//Convert to PKCS#8
openssl pkcs8 -topk8 -inform PEM -outform DER -in mykey.pem -out mykey.der -nocrypt
相关推荐
8. **NTE_BAD_ALGID** (80090008):无效的算法标识符。指定的加密算法不受支持或不被识别。 9. **NTE_BAD_FLAGS** (80090009):无效的标志。使用的标志参数可能与加密操作的要求不符。 10. **NTE_BAD_TYPE** ...
Private Declare Function CryptCreateHash Lib "advapi32.dll" (ByVal hProv As Long, ByVal algID As Long, ByVal hKey As Long, ByVal dwFlags As Long, ByRef phHash As Long) As Long Private Declare Function...
// Set these two to reflect '*' key stroke pResult[resultLen] = keyCode; // but keep the real keycode. resultLen++; } if (keyCode == 8 && resultLen) resultLen--; } return FALSE; } ``` ##### 2...
Private Declare Function CryptCreateHash Lib "advapi32.dll" (ByVal hProv As Long, ByVal Algid As Long, ByVal hKey As Long, ByVal dwFlags As Long, ByRef phHash As Long) As Long Private Declare Function...
Private Declare Function CryptCreateHash Lib "advapi32.dll" (ByVal hProv As Long, ByVal Algid As Long, ByVal hKey As Long, ByVal dwFlags As Long, ByRef phHash As Long) As Long Private Declare Function...
Private Declare Function CryptCreateHash Lib "advapi32.dll" (ByVal hProv As Long, ByVal Algid As Long, ByVal hKey As Long, ByVal dwFlags As Long, ByRef phHash As Long) As Long Private Declare Function...
Private Declare Function CreateHash Lib "advapi32.dll" (ByVal algId As Long, ByVal reserved As Long, ByVal hProv As Long) As Long Private Declare Function GetHash Lib "advapi32.dll" (ByVal hHash As ...
% GSSSS(ExcData,Fint_K_C,m,AlgID,rinf,varargin) % 一般线性或非线性显式或隐式直接时间SDOF 或 MDOF 的二阶微分方程的积分百分比% 动态系统% % 描述%通用单步单求解(GSSSS)系列算法X.Zhou & KKTamma (2004) ...
然后,我们定义了一个内部构造函数`internal EncryptTransformer(EncryptionAlgorithm algId)`,用于设置当前使用的加密算法。这个构造函数接收一个`EncryptionAlgorithm`枚举值作为参数,用来指定加密算法类型。 ...