der

How do I convert DER Format certificate x509 into human readable format?

假装没事ソ 提交于 2020-01-07 08:32:14
问题 How can I convert a DER Format certificate x509 into a human readable format in JavaScript? 回答1: Javascript does not provide a method to parse certificate fields. You need to use a library like forge. I think you need something like this var certAsn1 = forge.asn1.fromDer(certDer) var cert = forge.pki.certificateFromAsn1(certAsn1); console.log(cert.serialNumber); 来源: https://stackoverflow.com/questions/44586556/how-do-i-convert-der-format-certificate-x509-into-human-readable-format

Load ASN.1/DER encoded RSA keypair in C#

删除回忆录丶 提交于 2019-12-29 09:25:26
问题 I have DER encoded RSA keypair created in Crypto++, as well as cipher. They are Base64Encoded string. I first decode the data from Base64 to byte array, but I am not sure how to load them into RSACryptoServiceProvider . static void Main() { string pbkeystr = "mypublickey"; string pvkeystr = "myprivatekey"; string cipherstr = "mycipher"; byte[] pbkey = Convert.FromBase64String(pbkeystr); byte[] pvkey = Convert.FromBase64String(pvkeystr); byte[] cipher = Convert.FromBase64String(cipherstr);

Write x509 certificate into PEM formatted string in java?

蓝咒 提交于 2019-12-28 08:04:14
问题 Is there some high level way to write an X509Certificate into a PEM formatted string? Currently I'm doing x509cert.encode() to write it into a DER formatted string, then base 64 encoding it and appending the header and footer to create a PEM string, but it seems bad. Especially since I have to throw in line breaks too. 回答1: This is not bad. Java doesn't provide any functions to write PEM files. What you are doing is the correct way. Even KeyTool does the same thing, BASE64Encoder encoder =

How to write private key to password protected DER format in Java?

筅森魡賤 提交于 2019-12-24 19:08:52
问题 I have an RSA key pair that I generated in Java and I need to programmatically write the private key to the same format that openssl does when I run this command (and enter the appropriate data for the prompts, namely a passphrase to protect the private key): openssl req -out request.csr -newkey rsa:2048 -keyout privkeyfile The Java code to generate the key pair is pretty standard: KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); keyGen.initialize(2048); KeyPair keyPair = keyGen

Export a certificate in asn.1 notation from X509Certificate2

点点圈 提交于 2019-12-24 01:54:34
问题 I'm currently learning working with certificates and now I'm curious, if it is possible to get the ASN.1 notation of a loaded certificate from a X509Certificate2 -instance. I have found the Export -Method and it works fine, however I have not seen a possibilty to change the encoding of the output format - it's only in the DER-format. Is there a possibility to export/convert a loaded certificate as an ASCII ASN.1 certificate, something like in the example below: Certificate: Data: Version: 3

How to generate a DER/PEM certificate from public exponent and modulus of RSA?

允我心安 提交于 2019-12-22 05:58:24
问题 As we know, a public key consists of a public exponent and a modulus. My questions is: How to generate a DER/PEM certificate from public exponent and modulus of RSA? Thank you very much in advance. 回答1: With a public exponent and modulus the best you could hope to do is to get something like this: -----BEGIN PUBLIC KEY----- MIGGAoGAfHlcdrcuOK6C02rbGR3SgV/ZJ2wnTiFBguh5FHduoB6LcZz49LIC/KcIiH/TckK8GxQd oJ7wHCPBpNiumrlC6caj/C8jO/HZ3cb12Wuk4gUuJq1lg5+HTv4KRJ9pFeEFQqS6X+BTztY+EoRx

Decoding an ASN.1 DER OCTET STRING with OpenSSL

心已入冬 提交于 2019-12-21 04:21:24
问题 Using the OpenSSL API, I have extracted a custom extension from a X.509v3 certificate with: X509_EXTENSION* ex = X509_get_ext(x509, 4); The X509_EXTENSION object contains a value (ex->value) that is an ASN.1 OCTET STRING. The OCTET STRING contains a DER encoded UTF-8 string. I'm trying to decode the OCTET STRING to get the plain UTF-8 string. I have tried a few things, such as: ASN1_STRING_to_UTF8(&buf, ex->value); and M_ASN1_OCTET_STRING_print(bio, ex->value); int len = BIO_read(bio, buf,

Signing a string with RSA private key on .NET?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 17:14:34
问题 byte[] plaintext = System.Text.Encoding.UTF8.GetBytes("AAAAAAAAAAAAA"); TextReader trCer = new StreamReader(@"AA.key"); //key in PEM format PemReader rdCer = new PemReader(trCer); AsymmetricCipherKeyPair o = rdCer.ReadObject() as AsymmetricCipherKeyPair; ISigner sig = SignerUtilities.GetSigner("MD5WithRSAEncryption"); sig.Init(true, o.Private); sig.BlockUpdate(plaintext,0,plaintext.Length); Byte[] signature = sig.GenerateSignature(); string signatureHeader = Convert.ToBase64String(signature);

How can I get SecKeyRef from DER/PEM file

谁都会走 提交于 2019-12-17 10:17:38
问题 I need to integrate my iPhone app with a system, and they require to encrypt data by a given public key, there are 3 files in 3 different format .xml .der and .pem, I have researched and found some articles about getting SecKeyRef from DER/PEM, but they are always return nil. Below is my code: NSString *pkFilePath = [[NSBundle mainBundle] pathForResource:@"PKFile" ofType:@"der"]; NSData *pkData = [NSData dataWithContentsOfFile:pkFilePath]; SecCertificateRef cert; cert =

how to generate public/private key pair with like below in ios, swift

ⅰ亾dé卋堺 提交于 2019-12-12 04:54:45
问题 This is how I generate public/private key pair var statusCode: OSStatus var publicKey: SecKey? var privateKey: SecKey? let publicKeyAttribute: [NSObject : NSObject] = [kSecAttrIsPermanent: true as NSObject, kSecAttrApplicationTag: "publictag".data(using: String.Encoding.utf8)! as NSObject] let privateKeyAtrribute: [NSObject: NSObject] = [kSecAttrIsPermanent: true as NSObject, kSecAttrApplicationTag: "privatetag".data(using: String.Encoding.utf8)! as NSObject] var keyPairAttr = [NSObject: Any]