In regular .net framework I can sign any assembly from Visual Studio project properties tab. I've created a simple console application and added a reference to class library (ClassLibrary1) which is signed by pfx with password. ClassLibrary1 contains ClassLibrary2 as reference which is not signed. When creating an object from ClassLibrary1 which uses reference from the 2nd one - I receive an exception during runtime:
My console application is also signed. This exception is an expected behaviour: no one would be able to replace my assembly with unsigned one.
Moreover I want to secure my plugin system: I want to check if my assembly is signed by a specific key using this code and this one.
It works as expected in regular dot net. But I want to make this work in NET CORE. When I try to reference unsigned assemblies I just get compiler warning that ClassLibrary1 doesn't have a strong name. But in the runtime I get no exception. I tried this with snk and pfx file. And moreover I can't get public key from net core assembly:
assemblyName.GetPublicKey();
It's simply return byte[0] as a result. How can I secure my assemblies in NET CORE to make sure no one could replace them with harmful ones.
Part of my netcore project csproj config:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>TestKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
P.S: I use VS 2017, .net core 2.0