private-key

How to read a password encrypted key with java?

本小妞迷上赌 提交于 2019-11-27 10:52:11
问题 I have private key stored in file in PKCS8 DER format and protected by password. What is the easiest way to read it? Here is the code I use to load unencrypted one: InputStream in = new FileInputStream(privateKeyFilename); byte[] privateKeydata = new byte[in.available()]; in.read(privateKeydata); in.close(); KeyFactory privateKeyFactory = KeyFactory.getInstance("RSA"); PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(privateKeydata); PrivateKey privateKey = privateKeyFactory

How to use public and private key encryption technique in C#

流过昼夜 提交于 2019-11-27 10:51:20
问题 I want to encrypt data using public/private key technique. I mean, encrypt with the public key of receiver and the receiver can decrypt with their own private key. How can I do that? Do you have any suggestion or sample code ? 回答1: Code example: private static string _privateKey; private static string _publicKey; private static UnicodeEncoding _encoder = new UnicodeEncoding(); private static void RSA() { var rsa = new RSACryptoServiceProvider(); _privateKey = rsa.ToXmlString(true); _publicKey

X.509: Private / Public Key

£可爱£侵袭症+ 提交于 2019-11-27 10:08:51
问题 We're trying to implement some functionality of a Web-Service from one of our partners. Now, the content which is beeing transmitted, should be encrypted with a public key, which we have to provide. The security-specification says that the public-certificate has to be X.509 standard. Doesn't X.509 rely on the private / public key method? Because I only get one .pem file, containing a private key, and a certificate, but no public key, using the following command: openssl req -new -x509 -days

Get a PrivateKey from a RSA .pem file [duplicate]

一世执手 提交于 2019-11-27 06:53:54
问题 This question already has answers here : Decrypting an OpenSSL PEM Encoded RSA private key with Java? (2 answers) Closed 2 years ago . Given this .pem file (generated with openssl and encrypted with a password): -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,AC009672952033EB 2wegzxf3MtncXS1CY3c..... .... .... -----END RSA PRIVATE KEY----- How do I get a PrivateKey object in Java? I wrote the following code but I cannot find the right way to get a KeySpec :

PrivateKey trust permissions for local machine “Trusted roots” certificates

五迷三道 提交于 2019-11-27 06:14:20
问题 I have a certificate that has to be imported into Certificates/Trusted Root Certification Authorities and has a corresponding private key. To actually access the key from code you need to set private key permissions to grant full access to particular IIS application pool. I totally understand that but the problem is that this can only be set on personal certificates and not trusted root ones. I've tried adding the same certificate to Personal store and the following code doesn't break:

How can I use an existing private key to a new iOS development certificate?

心已入冬 提交于 2019-11-27 05:07:39
问题 For aesthetic reasons, I would like to use the same private key that I used to create my distribution certificate a while ago, to create a new development certificate (my old one expired). But the "How to create a development certificate:" on the iOS provisioning portal require that you use Keychain Access create a new key. When I try to do Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority With "(my key name)" the Certificate Assistant doesn't

Can't get private key with openssl (no start line:pem_lib.c:703:Expecting: ANY PRIVATE KEY)

Deadly 提交于 2019-11-27 03:45:28
问题 I have a .key file, when I do openssl rsa -text -in file.key I get unable to load Private Key 140000419358368:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: ANY PRIVATE KEY Also I have a .cer file and when I do openssl x509 -text -in file.cer I get unable to load certificate 140387178489504:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE But if as pointed here I run the command like: openssl x509 -text

How to Grant permission to user on Certificate private key using powershell?

青春壹個敷衍的年華 提交于 2019-11-27 03:09:01
问题 Certificate is already installed on machine. Now I want to give read permission on PrivateKey of Certificate to application user. 回答1: Here is the Answer. Created a powershell script file AddUserToCertificate.ps1 Here is the content for script file. param( [string]$userName, [string]$permission, [string]$certStoreLocation, [string]$certThumbprint ); # check if certificate is already installed $certificateInstalled = Get-ChildItem cert:$certStoreLocation | Where thumbprint -eq $certThumbprint

Encrypting with RSA private key in Java

自古美人都是妖i 提交于 2019-11-27 01:25:05
问题 I'm trying to encrypt some content with an RSA private key. I'm following this example: http://www.junkheap.net/content/public_key_encryption_java but converting it to use private keys rather than public. Following that example, I think what I need to do is: Read in a DER-format private key Generate a PCKS8EncodedKeySpec call generatePrivate() from KeyFactory to get a private key object Use that private key object with the Cipher object to do the encryption So, the steps: The key was

How to convert Byte array to PrivateKey or PublicKey type?

大憨熊 提交于 2019-11-27 00:36:55
问题 I am using RSA algorithm to generate public and private key final KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM); keyGen.initialize(1024); final KeyPair key = keyGen.generateKeyPair(); final PrivateKey privateKey=key.getPrivate(); final PublicKey publickey=key.getPublic(); after that these keys are encoded using Base64 encoder and save it into database. How to convert this encoded String to Private and Public Key Type in java is to decrypt file. when decoding this String