How to Re-Sign a PKCS7 ?

Hello
I want to re-sign a pkcs7
I tryed to merge 2 PKCS7 with each signature
how can I do the job ?
*1/read the info in the PKCS7 allready signed (its a detached signature)*
signedData = new CMSSignedData(
new CMSProcessableFile(file),
new BufferedInputStream( new FileInputStream(filePKCS7)));
*2/ sign a new PKCS7*
CMSSignedDataGenerator signGen = new CMSSignedDataGenerator();
CMSProcessable content = new CMSProcessableFile(file);
addSignerInSignedDataGenerator(signGen, cert, privateKey, sDigestAlgorithm);
signedDataNew = signGen.generate(content, bAttachFile, sProviderName);
with
     public static void addSignerInSignedDataGenerator(
               CMSSignedDataGenerator signGen,
               X509Certificate cert,
               PrivateKey privateKey,
               String sDigestAlgorithm)
     throws CertStoreException, CMSException, InvalidAlgorithmParameterException, NoSuchAlgorithmException,
     NoSuchProviderException
          CertStore certs = generateCertificateStore(cert);
          signGen.addSigner(privateKey, cert, sDigestAlgorithm);
          signGen.addCertificatesAndCRLs(certs);
*3/ try to merge the 2 PKCS7*
how to merge signedDataNew and signedData ?
*4/ store the PKCS7 merged*
signedData.getEncoded();
There another way to do this ?
thanks !
best regards
David KELLER
Edited by: davidkeller on Oct 7, 2008 8:17 AM

I do this and it seems to work
if(filePKCS7 == null || !filePKCS7.exists())
throw new IOException("file signature not exist : " + filePKCS7);
* Append a new signer in the PKCS7
CMSSignedData sp = new CMSSignedData(
new CMSProcessableFile(file),
new BufferedInputStream( new FileInputStream(filePKCS7)));
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
gen.addSigners(sp.getSignerInfos());
gen.addCertificatesAndCRLs(sp.getCertificatesAndCRLs("Collection", "BC"));
CMSProcessable content = new CMSProcessableFile(file);
addSignerInSignedDataGenerator(gen, cert, privateKey, sDigestAlgorithm);
signedData = gen.generate(content, bAttachFile, sProviderName);
its seems to be ok
date sign : Sun Oct 05 21:36:01 CEST 2008
date sign : Tue Oct 07 18:24:15 CEST 2008
date sign : Tue Oct 07 18:24:25 CEST 2008
verify : true
Is it the best way to do this ?

Similar Messages

  • I singed into CC on my home computer, now I cant sign in at work? How can I sign in at work?

    I singed into CC on my home computer, now I cant sign in at work? How can I sign in at work? Isn't there an option to sign out of all other devices?

    If the IT dept. at your former employer knows what they're doing, they have already had access to everything on your work computer. As to transferring your data to your home computer, read here:
    https://discussions.apple.com/docs/DOC-3141

  • How do I sign my VB / VS 2010 based shared COM add-in for Excel so it loads when the user has checked "Require application add-ins to be signed by a trusted publisher"?

    My COM add-in is developed using VS 2010 and VB. It's a shared COM add-in (not VSTO) and it works with Excel 2007 - 2013. My installer is signed with a code signing certificate but it would appear that my add-in's .dll should also be signed if the user has
    checked the "Require application add-ins to be signed by a trusted publisher" option.
    The "Sign the assembly" option is checked in my add-in's VB -> My Project -> Signing. I have a .snk file selected which I seem to recall generating 6 or 7 years ago when I ported the COM add-in from VB6 to .NET. 
    I have an up-to-date Comodo code signing certificate (a pfx file called MyCompanyCodeSigningCertificatePrivateKey.pfx) which I purchased to use with the installer and was wondering if and how I could use this.
    I tried selecting my pfx file in the My Project -> Signing -> "Choose a strong name key file" dialog. It made a copy of the pfx file in my project folder but when I tried to build the project, I got the following error:
    Error 1 Cannot import the following key file: MyCompanyCodeSigningCertificatePrivateKey.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the
    following key container name: VS_KEY_C0B6F251F0FB6016
    After a little research, I found out I might be able to use signtool to sign the dll in a post-build step.
    I added the following command to the post-build event, before the command I use to regasm the assembly.
    "path to signtool\signtool" sign /f "MyCompanyCodeSigningCertificatePrivateKey.pfx" /p "xxxx" /v "$(TargetPath)"
    When I built the project, the dll appeared to get signed (the output window showed a bunch of confirming text as well as "Successfully signed: c:\MyAddIn\bin\Release\MyAddIn.dll") but the next step in the post-build (regasm myaddin.dll /codebase)
    issued a warning RA0000 (see below) but reported "Types registered successfully".
    Here's the message I get from regasm, even though the output window says the dll was sucessfully signed:
    RegAsm : warning RA0000: Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.
    Types registered successfully
    I'm not using a shim if that makes a difference.
    How do I sign my add-in so it loads when the user has checked "Require application add-ins to be signed by a trusted publisher"?
    Any tips would be appreciated.

    Hello,
    Why do you need to use the regasm utility from the post-build action?
    There is a difference between signing the assembly with a strong name and digital signature. The
    How to: Sign an Assembly with a Strong Name article in MSDN explains how to sign an assembly with a strong name (.snk). See
    How to digitally sign a strong named assembly for adding a digital signature.
    You may also find the
    What's the Difference, Part Five: certificate signing vs strong naming article helpful.

  • How do i sign up for a new e-mail address @icloud or @me; and can I have more than one e-mail address?

    how do i sign up for a new e-mail address @icloud or @me; and can I have more than one e-mail address?

    Cessna007 wrote:
    how do i sign up for a new e-mail address @icloud or @me; and can I have more than one e-mail address?
    You create an @icloud.com address in the first place by signing into Settings>iCloud with your Apple ID and choosing an addres - you can only create an @icloud.com address, not @me.com.
    Then if you want further addresses on the same account you can add up to three 'email aliases' - these are additional addresses (not accounts) which deliver into the same inbox as the main account. (In fact it's a good idea to give out alias addresses, rather than the main address, because if they attract spam you can easily change them.) (New aliases can only be @icloud.com ones; @me.com addresses cannot now be created.)
    You should be aware before you start that once you've created an alias you cannot turn that address into a full iCloud account or move it to another account.
    More information on aliases here: http://help.apple.com/icloud/#mm6b1a490a

  • How do i sign in onto facetime if it keeps on sayin 'an error occured during activation'.?

    How do i sign in onto facetime if it keeps on sayin 'an error occured during activation'.?

    iOS: Troubleshooting FaceTime        
    iOS: Troubleshooting FaceTime and iMessage activation
    iOS: Using FaceTime                               
    FaceTime, Game Center, Messages: Troubleshooting sign in issues

  • HT204053 Can I set up two iCloud accounts on my IPAD3 at the same time? If not how do you sign out of one to sign in to another?

    Can I set up two iCloud accounts on my IPAD3 at the same time? If not how do you sign out of one to sign in to another?

    Welcome to the Apple community.
    You can add more than one account to your iPad, but you can only have one primary account. Secondary accounts which you can add at settings> mail, contacts, calendars do not have all the features of a primary account such as photo stream.

  • I just bought a macbook pro and want to use my own iCloud account for my iPhone. How do I sign off of the current account on my iPhone and sign in with my own iCloud account?

    I just bought a macbook pro and want to use my own iCloud account for my iPhone. How do I sign off of the current account on my iPhone and sign in with my own iCloud account i set up my mac?

    On your phone, Go to "Settings", "iCloud", scroll to the bottom and "sign out."  Assuming you have the the account password/security info of the current account, it will delete everything iCloud related upon your approval (don't worry, everything will remain in the cloud.)  Once signed out, in the same settings location (under "Settings", "iCloud") sign in using your Apple ID and Password.
    Hope this helps.

  • How can I sign out of my apple account on my iPhone with out erasing everything

    How can I sign out of my apple account on my iPhone with out erasing everything

    I meant apple ID

  • So I bought an iphone 4 from ebay and when I got it it was already signed into an icloud account. When I contacted the seller he said he would try to get the password but i haven't heard from him. How can I sign out of her icloud w/out the password

    So I bought an iphone 4 from ebay and when I got it it was already signed into an icloud account. When I contacted the seller he said he would try to get the password but i haven't heard from him. How can I sign out of her icloud w/out having to have the last users password

    Bmscotr5 wrote:
    How can I sign out of her icloud w/out having to have the last users password
    You cannot.
    Removing a device from a previous owner’s account
    Try and get a Refund.

  • How can I sign up with Enterprise program, while I have an active membership of the iOS developer program?

    How can I sign up with Enterprise program, while I have an active membership of the iOS developer program?
    I have bought a memership for the iOS Developer program.
    I have created an in-house app.
    Now I want to publish it to all employees without registering the devices.
    So..
    I go to their website and try to sign up for the enterprise program, image shown below:
    http://s29.postimg.org/q06ylh5o6/Clipboard01.jpg
    Within the image above, I click continue...
    http://s14.postimg.org/46lqcpy74/Clipboard02.jpg
    Then I am taken to the image above, there I need to select a program, but I already have a program, the iOS developer program!  And the checkbutton of that program, is disabled. If I try to click continue at this page, without sleecting a program, a javascript-box shows "You have to select a program before continuging"...
    Do I need to unsubscribe my iOS developer program, to then register it again? Lol!
    PS: no clue where I should post this, looked over the forums and could not see anything related to singing up, registering for a program...

    Our apps came offline automatically shortly after this as iTunesConnect thought we had not renewed our license, even though we had several weeks ago.
    We had a brief panic as our apps were offline for 12 hours, which is how long it took Apple Support to work out what was wrong and hook things up. 
    I suggest you contact them ASAP to get this fixed so you don't get that iTunesConnect alert to your phone 'Your app status has been changed to Pending Contract'.

  • How do I sign up for an itune's account without a credit card if I already have an apple ID?

    How do I sign up for an itune's account without a credit card if I already have an apple ID?
    There is no none option for payment method, even if I buy a free app.
    I have no credit card.

    What I can see here is that you have 2 options -
    You can use your Apple ID to create your account, but you must enter a credit card.
    ***Once you have successfully created the account with a credit card, you can simply remove the card from your account.
    Or you can create an iTunes Store account with a free application. However, you cannot use this Apple ID. You must start the process from the beginning with a different email address. This article shows you how:
    Create an iTunes App Store account without a credit card
    http://support.apple.com/kb/HT2534

  • HT203167 how can i sign into my itunes account?

    How can i sign into my itunes account?

    Select Store adn click Sign in at top right of the iTunes window.
    Put in your username and password..

  • How can i sign into my icloud account on my pc

    How can i sign into my icloud account on my pc?

    In the iCloud Control Panel, if you have an iCloud account just enter the ID and password and sign in.

  • How can i sign out my Apple ID on my iPhone and sign in other?

    My friend have lost the phone i want to create his icloud for him so we can track the phone, but how can i sign out apple ID on my phone and sign in his and set up icloud and might find the phone?

    Change your password. https://appleid.apple.com

  • HT5577 how do you sign in to apple id to make changes if you lost recovery key..

    how do you sign in to apple id to make changes if you lost recovery key and removed one of my trusted devices  they are both still associated but only one is trusted my macbook pro is still trusted but neither it or the 5c can get pass the log in section where it asks for the recovery key!!!!!!!!
    <Edited By Host>

    Going to need a lot more info on what your are trying to do and why you are doing it.
    Signing into an Apple ID is easy. Open whatever needs and Apple ID and sign in using the ID name, usually a email address, and the password associated with that name. you will then be signed in.
    And please refrain from the profanity.

Maybe you are looking for

  • Too much 0 in the report - depends on the pc

    Hi @ all, I have some problems with my laptop by executing queries. It puts too much 0 in the numbers. Instead of 10,00 the Bex displays 10.000,00. I checked all the settings, but everything is o.k.. Maybe it depends on the Bex version? I use Microso

  • A Headache of a problem! After Effects to DVDSP

    Hello to every one! I am having a heck of a time trying to figure this out. I will try and sum this up as best as I can The goal of the project is - To create a motion menu in After Effects, export and bring into DVD Studio Pro and add buttons for th

  • EasyDMS - Private & Public folder creation - Error Message no. 1R579

    Hi, I want you to validate my approach for creating Public and Private folders in DMS. Create a document type FLD,assign number range as "internal or external number assignment",set internal and external number range. Now when i login in easyDMS and

  • Printer CM3530 EWS Password required. How do you clear printer EWS password so its no longer needed?

    HP Community    I have a problem trying to manage my printer using HP Web Jet Admin. Every time we try to push a policy it prompts us for a EWS password. Can I get some simple assistance or input on why this prompt arrives and how to get around it. 

  • Can't open Indesign after update

    I opened Updater and allowed updates to Indesign CS5, Bridge CS5, and Photoshop CS5.  I received this error message: Extend Script Toolkit 3.5.1 Update Installation failed. Error Code: U44M1P7 Now I cannot open any of my Indesign documents.  Also, I