用crypto生成公钥私钥,下面的代码不会报错,但是每次运行都会重新生成密钥
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
modulusLength:1024
});
const consumer = new OAuth("https://henryfy.atlassian.net/plugins/servlet/oauth/request-token",
"https://henryfy.atlassian.net/plugins/servlet/oauth/access-token",
"myKey",
privateKey,
"1.0",
"http://localhost:8084/sessions/callback",
"RSA-SHA1");
想用读取文件的形式来做,把privateKey固定,但是报错
privateKey = fs.readFileSync('jira_privatekey.pem',"utf-8")
internal/crypto/sig.js:105
const ret = this[kHandle].sign(data, format, type, passphrase, rsaPadding,
^
Error: error:25078067:DSO support routines:win32_load:could not load the shared library
at Sign.sign (internal/crypto/sig.js:105:29)
at exports.OAuth._createSignature (d:\OauthTest\node_modules\oauth\lib\oauth.js:211:64)
at exports.OAuth._getSignature (d:\OauthTest\node_modules\oauth\lib\oauth.js:90:15)
at exports.OAuth._prepareParameters (d:\OauthTest\node_modules\oauth\lib\oauth.js:300:16)
at exports.OAuth._performSecureRequest (d:\OauthTest\node_modules\oauth\lib\oauth.js:309:31)
at exports.OAuth.getOAuthRequestToken (d:\OauthTest\node_modules\oauth\lib\oauth.js:542:8)
at Object.<anonymous> (d:\OauthTest\six.js:17:10)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32) {
opensslErrorStack: [
'error:0E076071:configuration file routines:module_run:unknown module name',
'error:0E07506E:configuration file routines:module_load_dso:error loading dso',
'error:25070067:DSO support routines:DSO_load:could not load the shared library'
],
library: 'DSO support routines',
function: 'win32_load',
reason: 'could not load the shared library',
code: 'ERR_OSSL_DSO_COULD_NOT_LOAD_THE_SHARED_LIBRARY'
}