Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
975 views
in Technique[技术] by (71.8m points)

encryption - The key not valid for use in specified state while using -pri

I am following this link to encrypt/decrypt passwords: https://docs.microsoft.com/en-us/previous-versions/aspnet/yxw286t2(v=vs.100)

I was able to encrypt passwords in web.config on the Remote Server. I can decrypt. I was able to create the RSA Key container and export it.

I am not able to create keys using the -pri tag: aspnet_regiis -px "SampleKeys" keys.xml -pri

It will only generate keys.xml for me if I take out the -pri. I get the error "The key not valid for use in specified state."

I did create the RSA container using the following: Create Keys

  1. From the (run as administrator) console prompt, change directory to C:WindowsMicrosoft.NETFramework64v4.0.30319
  2. Execute the command to create the keys: aspnet_regiis -pc "ConnectionKeys" –exp
  3. Execute the command to export the keys:
  4. From the (run as administrator) console prompt, execute the following command line to grant permissions: aspnet_regiis -pa "ConnectionKeys" "IIS_IUSRS"

I am able to encrypt/decrypt on the remote server. However, I need to be able to export the keys and have the rest of the developers on my team use them. I first tried testing on my local machine.

If I create keys from my machine, I am able to encrypt/decrypt. If I copy web.config from the Remote Server to my machine and export/import the keys.xml, I get the following error: "The data to be decrypted exceeds the maximum for this modulus of 128 bytes"

question from:https://stackoverflow.com/questions/65910944/the-key-not-valid-for-use-in-specified-state-while-using-pri

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...