Add support for delay-signing with a public only keyfile#513
Conversation
Problem: Mono.Cecil attempts to strong sign an assembly with a StrongNameKeyPair that only contains a public key. This throws an exception as a private key is required to complete the sign. However, it should be supported to place the public key into the AssemblyName without signing the assembly. Fix: Allow clients to pass in the public key. This should be passed in alongside a StrongNameKeyPair. If the strong name fails to calculate a PublicKey and throws the ArgumentException, set the PublicKeyBytes to the assembly instead. Furthermore, do not attempt to sign/strong name the assembly in this scenario.
…th the public byes.
|
@jbevain thoughts on this one? |
|
Yes yes yes. Just rename |
|
Also a test would be nice. |
|
Reviewing this, why not simply setting the PublicKey of the assembly name before writing? |
|
@SimonCropp I don't see why this is needed and why you can't create a delay signed without having this new parameter. As far as I can tell, you can create an AssemblyDefinition with the proper flags and the proper public key, and it will be considered delay signed. |
|
@jbevain and @SimonCropp Isn't that what I'm doing? I'm passing in the PublicKey to be set into the AssemblyDefinition that is used to write the assembly. There's already the StrongNameKeyPair for signing with a private key. If we want to allow delay signing, we should allow people to pass in the public key bytes. |
|
@ryknuth yeah but you can already set the PublicKey on the assembly definition:
Without having to add a new API to the |
|
I see, let me paste some code here to ensure I understand. The change would be completely in Fody. The added line is this: Am I understanding correctly? |
|
I think it looks correct. You might have to turn on a flag as well on the Module:
But I'm not 100% sure. |
|
With delay signing, we shouldn't set StrongNameSigned if I recall correctly since it actually isn't signed. |
Problem:
Mono.Cecil attempts to strong sign an assembly with a StrongNameKeyPair that only contains a public key. This throws an exception as a private key is required to complete the sign. However, it should be supported to place the public key into the AssemblyName without signing the assembly.
Fix:
Allow clients to pass in the public key. Clients should determine if they have a proper StrongNameKeyPair that includes the private key. If not, pass along the keyfile to be used as the public key. In the case of using the public key bytes, do not attempt to sign the assembly and do not mark it as signed.