none
Convert a .PFX file to .SNK file RRS feed

  • Question

  • Hi all,

    Is it possible to convert an existing .pfx file to a .snk file with a public/private key in it ?
    SN.EXE seems only be able to generate a new key pair .snk file.

    • Moved by spacewrangler Saturday, April 23, 2011 3:45 PM (From:Building Development and Diagnostic Tools for .Net)
    Tuesday, April 19, 2011 7:55 AM

All replies

  •  

    Hi Jonas,

     

    Welcome to the MSDN forum!

     

    You can try the command in VS command Prompt.

    I assembly the pfx file names keypair.pfx, then key the command below

    "sn -p keypair.pfx key.snk"

    It will need to key the password of pfx.file.

    After key password, you will get snk file in the same folder.

     

    I hope this can help you resolve your problem.

    Have a nice day!


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Wednesday, April 27, 2011 3:45 AM
    • Unmarked as answer by Jonas VH Wednesday, May 4, 2011 1:18 PM
    Friday, April 22, 2011 10:58 AM
  • Hi Paul,

    Thx for your warm welcome :)

    I know you can use sn.exe for converting a .pfx file to .snk file, but my .pfx file has a private as well as a public key in it.
    While converting to a .snk file i want to copy this private and public key combination into my .snk file and this can't be done by SN.EXE and the -p switch:

    SN.EXE -p: Extracts the public key from the key pair in infile and stores it in outfile.

    Later on I want to use this .snk file in combination with AL.EXE for singing my assembly files via switch '/keyfile'.

    Wednesday, May 4, 2011 12:50 PM
  • Hi Jonas,

    We are in a similar situation. How did you resolve your issue?

     

    Thanks,

    Sudhir

    Thursday, August 4, 2011 3:17 PM
  • Hi Sudhir,

    I couldn't find a way to create such a .snk file, but i did find a way to resolve my problem.
    What i did was creating a 'key container' via SN.exe which stores my public and private key in order to strong name my assemblies in an automated way:

    sn -i mykey.pfx container_name

    You only need to enter the pfx password once at the creation of the container.

    Tip: here is a little tool that let you view your containers stored on your computer:
    http://www.jensign.com/KeyPal/index.html

    Wednesday, August 10, 2011 10:11 AM
  • Hi Sudhir,

    I have the same problem and I tried your solution. However, after creating a key container with "sn -i myPfx.pfx obruendl" and adding the key container to the linker options in visual studio 2010, I get the follwing error message:

    Error    1    error LNK1256: ALINK operation failed (80040405) : The key container name 'obruendl' does not exist    C:\work\FpgaManagerTrunk\Projects\Win7\ManagedCpp\LINK    FpgaManager

    What did I miss?

    Wednesday, November 12, 2014 11:12 AM
  • The C# crypto API makes this possible as an answerer on StackOverflow pointed out.

    http://stackoverflow.com/questions/8174229/how-to-create-a-snk-from-pfx-cer

    And referenced in a comment is a link to a Visual Studio solution that when built successfully converted my PFX file to a SNK file:

    https://github.com/aarnott/pfx2Snk

    HTH

    --Kaleb

    Tuesday, June 2, 2015 4:45 PM