Hi! I’m a hobbiest developer. I’m trying to execute this command using C functions in objective C. The output using this subcommand and its functions are very different. I’d been reading the open source smime.c file but I don’t understand where is my mistake. Nevertheless I don’t know where I can get a detailed documentation of the flags. Below I paste my code and a stack overflow question I had asked. Thanks for your time. openssl smime -sign -signer *certificate.cer* -inkey *myKey* -outoutFile.xml.cms -in *infile.xml -outform PEM -nodetach I do try to do this in Objective-C, but the length of the string which I end up is very different. SSL_library_init(); OPENSSL_add_all_algorithms_noconf(); //Load the private key NSString *privateKeyPath = [[NSBundle mainBundle]pathForResource:@"nameOfPrivateKeyFile" ofType:@"”]; BIO* bio = BIO_new_file([privateKeyPath cStringUsingEncoding:NSUTF8StringEncoding], "rb"); if (!bio) {NSLog(@"Error %s (%d)",strerror(errno), errno); } EVP_PKEY* pkey = NULL; PEM_read_bio_PrivateKey(bio, &pkey, NULL, NULL); NSLog(@"problem"); } BIO_free_all(bio); // Load the certificate X509* certificate = NULL; NSString *certificatePath = [[NSBundle mainBundle]pathForResource:@"certificateFilePath" ofType:@"cer"];bio = BIO_new_file([certificatePath cStringUsingEncoding:NSUTF8StringEncoding], "rb"); certificate = PEM_read_bio_X509_AUX(bio, NULL, NULL, NULL); BIO_free_all(bio); PKCS7* pkcs7 = PKCS7_sign(NULL, NULL, NULL, NULL, PKCS7_PARTIAL); PKCS7_sign_add_signer(pkcs7, certificate, pkey, NULL, PKCS7_PARTIAL); PKCS7_final(pkcs7, NULL, PKCS7_PARTIAL); NSLog(@“Problem in PKCS7"); } BIO_free_all(bio); NSString *fileToWritePath = [[NSBundle mainBundle]pathForResource:@"fileToEncrypt" ofType:@"xml"]; bio = BIO_new_file([fileToWritePath cStringUsingEncoding:NSUTF8StringEncoding], "rb"); NSString *fileToSignPath = [[NSBundle mainBundle]pathForResource:@"fileToSign" ofType:@"xml"]; BIO* bioIn = BIO_new_file([secondTicketPath cStringUsingEncoding:NSUTF8StringEncoding], "rb"); if (!bioIn) { NSLog(@"Error %s (%d)",strerror(errno), errno); }NSLog(@"Error writting file "); } The expected result is this file in printed in text format -----BEGIN PKCS7----- MIIG7QYJKoZIhvcNAQcCoIIG3jCCBtoCAQExCzAJBgUrDgMCGgUAMIIBWAYJKoZI ……. qz5dxSDJ4rYBoio1ZncTIwUnpHAWwe2OTWt9wSEu3d5elPFXQ mw ==-----END PKCS7—— but I obtain, the length of the string is completely different (short) I cannot get the -----END PKCS7------ part of the message. Now the first part of the message seems right. But not the last. -----BEGIN PKCS7----- MIIF3QYJKoZIhvcNAQcCoIIFzjCCBcoCAQExDzANBglghkgBZQMEAgEFADAPBgkq ……. aPdcT7Wg5StNrGYsmmRzxaY= Thanks |
-- openssl-users mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users