Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Strong Name Sign .NET Assemblies via SNK

Strong Name Sign .NET Assemblies via SNK
April 25, 2024 4 min read BEN ABT
Csharp .NET

Strong Name Signing is a mechanism in .NET development that ensures the integrity and authenticity of assemblies. It is based on a public-private key procedure.
Contrary to what many assume, this is not a security mechanism, but a mechanism to ensure the uniqueness of the identity. It is therefore also recommended to store both private and public keys directly in the repository - and not to hide them; especially not in open source projects.

Immo Landwerth (.NET PM Microsoft) https://twitter.com/terrajobst/status/848560465672151040

Dear OSS maintainers: unless your keys are in hardware or used for sandboxing, just check in your .snk files. It’s much easier.

Also the corresponding note in the official documentation :

Do not rely on strong names for security. They provide a unique identity only. … If you are an open-source developer and you want the identity benefits of a strong-named assembly for better compatibility with .NET Framework, consider checking in the private key associated with an assembly to your source control system.

Signing-Benefits

In the days of the .NET Framework, there were corresponding runtime benefits, such as identity management in the Global Assembly Cache (GAC), certain behaviors, etc., all of which no longer exist since .NET Core or .NET 5+. Strong naming is no longer validated at runtime. The only benefit today is the proof of identity.

How do you sign?

In principle, Tools are available as a CLI application and Visual Studio also contains direct functionalities.
However, the better idea is to integrate the signing directly in the CI/CD system so that a stable and validatable automatism is created.

Creating the Key Pair

The CLI tool SN.exe (Strong Name Tool) is required for the initial creation of the SNK file, which is required for signing.

It can either be downloaded and used or you can simply use the integrated CLI of Visual Studio (Developer Command Prompt) with the solution open in Visual Studio.

The command sn -k MyKeyName.snk is used to create the keypair. The name of the SNK file is usually the name of the solution - not the project itself.

PowerShell
 1**********************************************************************
 2** Visual Studio 2022 Developer Command Prompt v17.10.0-pre.4.0
 3** Copyright (c) 2022 Microsoft Corporation
 4**********************************************************************
 5
 6C:\source\benabt\ba-StrongOf>sn -k MySolutionName.snk
 7
 8Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.0
 9Copyright (c) Microsoft Corporation.  All rights reserved.
10
11Key pair written to MySolutionName.snk

The file MySolutionName.snk is now located next to the solution file - in this example MySolutionName.sln.

Next, the public key is extracted with the command sn -p MyKeyName.snk MyPublic.snk; another binary file. The public key contains a key that is required for the next steps.
The command that displays the public key as a hash is executed:

Shell
1C:\source\benabt\ba-StrongOf>sn -tp public.snk
2
3Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.0
4Copyright (c) Microsoft Corporation.  All rights reserved.
5
6Public key (hash algorithm: sha1):
7002400000Public-Key-Output11111111111

Now we are ready to sign

Configure projects

Usually all projects in a solution are signed and all use the identical identity signing key pair.

The easiest way to configure this is via the Directory.Build.props , so that this central path configures all projects; alternatively, all subsequent configurations can also be configured individually directly in the csproj files, with increased effort.

The Directory.Build.props is extended by the following entries:

XML
1<PropertyGroup>
2    <SignAssembly>true</SignAssembly>
3    <AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)MyKeyName.snk</AssemblyOriginatorKeyFile>
4
5    <PublicKey>002400000Public-Key-Output11111111111</PublicKey>
6</PropertyGroup>

Once the public key has been entered here, the public key file (in this case public.snk) can be deleted from the file system.

The configuration is now complete. All assemblies are now automatically signed during the build process 🎉

Verify

The sn -vf MyAssembly.dll command can now be used to check whether the signing was successful. This works both locally during development time and with the assemblies that are located in the NuGet package, for example.

PowerShell
1C:\source\benabt\ba-StrongOf>sn -vf StrongOf.dll
2
3Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.0
4Copyright (c) Microsoft Corporation.  All rights reserved.
5
6Assembly 'StrongOf.dll' is valid

References

Open source examples that use SNK signing:

  • https://github.com/mycsharp/HttpUserAgentParser
  • https://github.com/BenjaminAbt/StrongOf

Docs

  • How to: Sign an assembly with a strong name
  • How to: Create a public-private key pair

Related articles

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026 - 11 min read

Containerizing .NET in 2026 Without a Dockerfile

Most .NET Dockerfiles repeat the same five steps: restore, publish, select the matching Microsoft runtime image, copy the output and start …

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026 - 12 min read

Problem Details in ASP.NET Core and .NET 11

builder.Services.AddProblemDetails() registers infrastructure. It does not create an error contract. An ASP.NET Core request can fail during …

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026 - 11 min read

Resilience in .NET with Microsoft.Extensions.Resilience

Retries are the most visible resilience strategy and the easiest one to misuse. Repeating a failing call can recover from a short network …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026
Problem Details in ASP.NET Core and .NET 11

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026
Resilience in .NET with Microsoft.Extensions.Resilience

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026
What Matters in ASP.NET Core 11

What Matters in ASP.NET Core 11

Sep 14, 2026

Tags

.NET (192) Csharp (96) ASP.NET Core (48) Azure (41) DevOps (17) Docker (14) Microsoft (14) EF Core (11) Microsoft MVP (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Security (9) Synology (9) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7) Bicep (6)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact