How can I import an RSA private key in PEM format for use with WebCrypto?

后端 未结 1 1457
傲寒
傲寒 2021-01-22 03:34

I\'m trying to use WebCrypto to sign a token with RSA-PSS, but I keep getting the error:

DataError: Data provided to an operation does not meet requirements


        
相关标签:
1条回答
  • 2021-01-22 04:05

    The header -----BEGIN RSA PRIVATE KEY----- in the PEM file is reserved to PKCS#1 keys, but WebCryptoApi does not support pkcs1, so you need to convert the key from pkcs1 to pcks8 using a tool like openssl

    # openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in pkcs1.key -out pkcs8.key
    
    0 讨论(0)
提交回复
热议问题