Senior Software Consultant C#, DevOps, Cloud

TLS PSK C# 0

How to support TLS PSK in C# (Pre-shared key)

TLS PSK (Pre-shared key) support in C# and .NET is very hard to come by. And is not natively supported. The SSLStream class in both .NET framework and .NET Core does not currently support getting SSL/TLS connections with the PSK or PSK-DHE Ciphersuites. The TLS-PSK implementation in OpenSSL has seen many security flaws in recent years, mostly because it is used only by a minority of applications. Please consider all alternative solutions before switching to PSK ciphers.  https://nodejs.org/api/tls.html To actually make this work you have to look for alternatives such as SSL termination proxies, or other programming languages all together. Resources to look into: wolfSSL C# Wrapper The wolfSSL C# wrapper gives the ability to make use of the TLS/SSL security perfected from IoT and embedded devices in C# development....

The most dangerous constructor in .NET 12

The most dangerous constructor in .NET

You should never instantiate a X509Certificate2 with the “new” keyword if you can avoid it, it is one of the most dangerous constructors in .NET – X509Certificate2, and if you do, you must be aware of these gotchas. Doing this wrong can mean you flood your disk with one-time use files, that are never removed. If you load in a new X509Certificate2 from a file by calling the public X509Certificate2 (string fileName, SecureString password); constructor, or similar constructor then you will without knowing it, create a brand new file on your disk, and this will happen every time you new it up. When you instantiate a X509Certificate2 from disk, say from a .pfx file, a new storage file of 3-4kb will be created in one of the following places depending...

Get started with .NET Generic Host 2

Get started with .NET Generic Host

Learn how Microsoft made it easier to bootstrap your new .NET Core project and get started with .NET Generic host. In the version bump to .NET Core 2.1, Microsoft added the .NET Generic Host, which is a non-web version of the WebHost that runs ASP.NET Core. The thought behind this addition was to allow us to re-use the tools that we use in ASP.NET, such as dependency injection and logging abstractions of Microsoft.Extensions. Later on, in ASP.NET Core 3.0 and 3.1, they moved ASP.NET to run on .NET Generic Host instead of the previously used WebHost, merging the two approaches together to make them truly the same. Now we can build our console applications, systemd’s, windows services or web apps on the same underlying hosting paradigm, with the same shared...

I will be able to find more opportunities and have better outreach in my future 0

Sharing is caring – Starting a blog

I got featured on Googles Featured list! As some of you may have noticed. I have started a blog at the start of the year. And I honestly did not expect it to do so well, and I didn’t expect that I would actually keep writing for it. The blog is a software developer blog, focusing on the issues, challenges, and solutions I face and find in my daily job as a freelance software consultant. So far it has mostly been about technical issues, but I am steering it toward describing some of the leadership-role challenges I face, and what I learn. I wish to include more stuff about being self-employed and what that feels like, but I am unsure of the interest. Why did I start the blog, you...

You are a trainer; you just don't know it yet! 1

You are a trainer; you just don’t know it yet!

You are a trainer; you just don’t know it yet! Most of us find ourselves in situations where we are training other people, not only in the ordinary presenter or mentor position but also in general situations where we need to convey ideas and knowledge. I recently participated in a 2-day facilitator course in JCI Denmark, and I learned a lot of tools, that I can use in my everyday consulting job. Tools that I would like to share with you guys as well. You are a trainer, you just don’t know it If you ask most developers if part of their job is to be a trainer, they would probably say no. But I beg to differ. Especially as developers, we need to share ideas all the time with...

Heres why you should use gRPC for everything 20

Heres why you should use gRPC for everything

gRPC makes calling services on other applications or servers very easy. It is blazingly fast, and uses protocol buffers to deliver very compact messages! gRPC is a “remote procedure call” system that initially was developed by Google, counterintuitively Google claims the g in gRPC does not stand for anything Google related, but come on, we know it does 😉 gRPC is a high-performance open-source RPC framework than can be used by almost any language. Most popular languages are supported with already written libraries and new ones are created every month. What does gRPC solve? gRPC makes calling services on other applications or servers very easy, it is based on Protocol buffers so you are able to create a very clear interface and service description with .proto files, and these proto...

Git does not remember username and password 4

Git does not remember username and password on Windows

Git does not remember username and password…! I was having issues, where Git would not remember my credentials for some repositories on Windows. Usually, the repositories are stored on AzureDevops and use Windows Authentication as default, with PAT (Personal Access Token) as a fallback. In this case, since I am not an employee in the company, I was given a PAT. But git kept asking me to enter credentials for every operation against the repository origin and it was making me crazy that it was not remembering my credentials. Make sure that you are using Windows Credentials manager If you are using Git on Windows, you should store your credentials in the Windows Credentials manager, so they are properly encrypted and protected. You can check this by running the following...

8

10 tips for conducting code reviews

Code reviews are a common part of most development teams workflow these days and for good reason. Code reviews give us a process of keeping code quality high, sharing knowledge. catching mistakes and keeping a consistent code base. If you use git, you probably already heard about pull-requests, which basically is a merge request with a code review requirement. I help teams learn to conduct productive and positive code reviews, so the process becomes an enjoyable part of their development life-cycle. Here are my 10 tips for conducting a productive and positive code review, that gives value to both the reviewer and the author(s). 1. Figure out what the goal of the code review is Something that often happens in teams that are new to code reviews, is that the...

0

You don’t need a IDesignTimeDbContextFactory

If you have ever gotten the error message, that tells you to add IDesignTimeDbContextFactory to your project, when doing EF Core migrations. This particular one: Unable to create an object of type ‘MyContext’. Add an implementation of ‘IDesignTimeDbContextFactory’ to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. You will probably be scratching your head, asking some questions and maybe even swear a little. Because the console will tell you to implemnt a IDesignTimeDbContextFactory so that is But don’t fret, you don’t need one. You can avoid it by having making sure of the following: The entire solution must be buildable and be able to run! If you have a project that cannot build, you can exclude it with the build configuration manager. Default constructor For the system to...

Nuget + XML docs + Swagger 11

Add NuGet package XML documentation to Swagger

Copy XML documentation from NuGet package to project build folder! At my current client, we are building an API that is put together by re-usable “API parts”, eg. ASP.NET Core Application Parts, which works wonders by the way. We can have multiple parts of the API split into small NuGet packages that can be re-used in other systems, that way we only have to implement system specific code, the rest is reused, including documentation etc. Talking about documentation, brings us directly to the issue. We use SwashBuckle to generate our Swagger definition and Swagger UI, and Swashbuckle requires XML documentation, to be able to include documentation from our Controllers and models. I thought we could probably just add a checkbox “Add XML documentation from NuGet package, on build”, but… Unfortunately...