Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,为何我用generate出来的rsa_key可以new成功,而用自己的就wrong tag呢? #19

Closed
xiaoxin1 opened this issue Nov 28, 2017 · 4 comments

Comments

@xiaoxin1
Copy link

这是generate出来的
-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAtv4b3uiZ95VbrmP1aHBa+dnCi1ji8zckQba5815A42DwKGZiDqwm
Q7B9BAXKSWyCOCqRd8f39LYuz4fAPuIXWLwzjXkrdYv2wcvOr+8NpIQ05/Kwy8kt
o3Pa3h3Q1Vw7ItWznnz28t6ejPrc0L1l3N/HkMrZnyH23x8FJ8o6k1FhBH28YpuC
9tg4KSbTiOnuHZ/TPnJ2hammRmFEKRpf1PV2lySjVrHXSAQ9+Sr4TwvQJGo9vWCx
QjIvgoD06l8NvnLPu4lsYI8BAkMIsd5rzIp6XYyEHV88+wx6e/AmYf1P4Tkd9XZ3
d8NdWkMd8wJgzncrCnYhmBA/6Wm7orINhwIDAQAB
-----END RSA PUBLIC KEY-----

这是我的:
-----BEGIN RSA PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlKp7UqlyK65w6k3qH99W
rp7xtiCNy1uHTX67nVadoOoMCDGXYJpdmQ8bZ3WQRPu0Xw9/s58c/F2BKLD+jAy9
mFZOyxfVCwgKww4mcKWwFApRG3tHwJaDdlm/iXQdpBB/X2mFk3CXmDNK086NXmJX
cMqIQKMxmfbEqSSAIdKzLK4gNrakP2i4/tNZt2yDvv458EuY+BfB+qYFl0LjVS9m
JoBbXH2dvRtljIrzw0906cPcd+8g/6va0j7beVKIICwrvqop1ziLF51KI5jF/fRf
QlgUKMeypwxXhkBcEM6oqPkonutm/8XdPDTXki7+qsCWJNFI2puJkOmYWZ4uGbPQ
hQIDAQAB
-----END RSA PUBLIC KEY-----

用上面的new出来没问题,也可以正常加解密,用我的错误 new rsa err: wrong tag

@spacewander
Copy link
Owner

看错误信息,你提供的公钥格式有问题?

@xiaoxin1
Copy link
Author

没有问题的,我还试了和这个公钥能配对的私钥,私钥没问题

@spacewander
Copy link
Owner

可否提供你的调用代码,以供我排查问题?

@xiaoxin1
Copy link
Author

不好意思,确实是公私钥格式不对,公钥是 rsa.KEY_TYPE.PKCS8 格式, 私钥是 rsa.KEY_TYPE.PKCS1 格式,我加了 key_type = resty_rsa.KEY_TYPE.PKCS8 可以用了,谢谢帮助

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants