private-key

Use and utility of .p12 certificate/file

爱⌒轻易说出口 提交于 2019-11-29 06:31:37
问题 What is the utility of .p12 file/certificate? I am not getting any correct definition when searching the internet: In one site I got "it stores server side certificates along with intermediate certificates and private key in one file. Its mostly used in Windows Machine" In another site i got "it binds a organizations public key with its name. My question is whether its public key or private key which is included in the .p12 certificate. 回答1: The .p12 contains both the private and the public

java.security.UnrecoverableKeyException: Failed to obtain information about private key

限于喜欢 提交于 2019-11-29 05:42:14
问题 I have the following lines to get the private key from key store on Android KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); keyStore.load(null); // generating key pair code omitted KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) this.keyStore.getEntry("alias", null); Everything works fine except that when the OS upgrades from Android 5.1.1 to Android 6.0.1, the 3rd line will throw java.security.UnrecoverableKeyException: Failed to obtain information about

push using multiple account / multiple identity on github / bitbucket

自古美人都是妖i 提交于 2019-11-29 03:47:56
问题 I have multiple accounts on github / bitbucket and one unique private-public key pair for each account. The problem occurs when I need to push to the repos created by the different accounts, I will almost certainly get access denied unless I am pushing into the default account (the account that I first created). Is there a way to switch to different credentials before pushing? I am using Source Tree on Macintosh machine. I'd prefer not to rename ~/.ssh/id_rsa manually whenever I need to push.

How to Export a Multi-line Environment Variable in Bash/Terminal e.g: RSA Private Key

岁酱吖の 提交于 2019-11-29 02:35:54
问题 One of our Apps github-backup requires the use of an RSA Private Key as an Environment Variable. Simply attempting to export the key it in the terminal e.g: text export PRIVATE_KEY=-----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA04up8hoqzS1+ ... l48DlnUtMdMrWvBlRFPzU+hU9wDhb3F0CATQdvYo2mhzyUs8B1ZSQz2Vy== -----END RSA PRIVATE KEY----- Does not work ... because of the line breaks. I did a bit of googling but did not find a workable solution ... e.g: How to set multiline RSA private key

Encrypting a BouncyCastle RSA Key Pair and storing in a SQL2008 database

百般思念 提交于 2019-11-29 00:28:19
I have a function that generates a BouncyCastle RSA key pair. I need to encrypt the private key and then store the encrypted private and public keys into separate SQL2008 database fields. I am using the following to get the keypair: private static AsymmetricCipherKeyPair createASymRandomCipher() { RsaKeyPairGenerator r = new RsaKeyPairGenerator(); r.Init(new KeyGenerationParameters(new SecureRandom(), 1024)); AsymmetricCipherKeyPair keys = r.GenerateKeyPair(); return keys; } This is returning the keys fine, but I am not sure how I can then encrypt the private key and subsequently store it in

KeyVault generated certificate with exportable private key

ぃ、小莉子 提交于 2019-11-28 21:36:03
I'm attempting to create a self signed certificate in KeyVault using the "Self" issuer. $policy = New-AzureKeyVaultCertificatePolicy -SubjectName "CN=$($certificateName)" -IssuerName "Self" -ValidityInMonths 12 $policy.Exportable = $true Add-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -CertificatePolicy $policy However, when getting the certificate back it doesn't appear to have a private key. Creating certificates directly in KeyVault doesn't seem hugely covered online, after digging into the rest API documentation and source code for the powershell cmdlets, I'm

How to read a password encrypted key with java?

梦想与她 提交于 2019-11-28 17:38:24
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.generatePrivate(encodedKeySpec); It works fine for unencrypted keys with the same specification. By the way,

X.509: Private / Public Key

家住魔仙堡 提交于 2019-11-28 17:15:32
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 365 -nodes -out ./cert.pem -keyout ./cert.pem Do I have to modify the command in order to create a

How to generate a RSA keyPair with a Privatekey encrypted with password?

家住魔仙堡 提交于 2019-11-28 15:52:37
问题 I want to generate a privatekey PKCS8 format encrypted with password, and I try with this code: String password = "123456"; KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); gen.initialize(2048); KeyPair key = gen.generateKeyPair(); PrivateKey privateKey = key.getPrivate(); PublicKey publicKey = key.getPublic(); FileOutputStream pvt = new FileOutputStream("d:\\pvt123456.der"); try { pvt.write(privateKey.getEncoded()); pvt.flush(); } finally { pvt.close(); } FileOutputStream pub =

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

倾然丶 夕夏残阳落幕 提交于 2019-11-28 12:14:38
This question already has an answer here: Decrypting an OpenSSL PEM Encoded RSA private key with Java? 2 answers 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 readFromPem(File keyFile, String password){ PemReader r = new PemReader(new InputStreamReader(new FileInputStream