Missing space in certificate subject variable


I am importing a certificate using the new step and then using the variable MyCertificate.Subject in the configuration. However, the value of this variable misses some spaces compared to the actual subject value. This is an example:

CN=ABCD - Test + SERIALNUMBER=1212121-UID:34343434, O=BLABLABLA // 3211121121, C=DK

gets incorrectly compressed to

CN=ABCD - Test+SERIALNUMBER=1212121-UID:34343434,O=BLABLABLA // 3211121121,C=DK


Hi Boyan,

When you say ‘the actual subject value’, where are you getting that from?

The subject in the certificate itself is stored in ASN.1 format. I suspect what you are seeing is the result of two different methods for rendering the ASN.1 into a string.

Is this causing a problem for you? If so, can ask what the problem is?


Hi Michael,

It could be me who is trying to use a different property. I use the following code below

var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
var cert = store.Certificates.Find(X509FindType.FindByThumbprint, "....", false)[0];
// This returns always the the version with spaces
var subjectName = cert.SubjectName.Name;

I am not sure if SubjectName.Name is supposed to be the same as Subject at all.



I’m sorry I didn’t get back to you on this.

This is the result of two different libraries used to convert the Subject name into a string.
Your code is obviously using the .NET Framework classes, while the Octopus code is using the BouncyCastle library (I promise there were good reasons why we didn’t simply use the .NET Framework).

I don’t think it’s that either is wrong, they’re just different formatting.

Is it causing you a problem?

Hi Michael,

It was causing issues for us as one library was using the subject name to find a certificate (we usually prefer using the thumbprint, but it was developed by a 3rd party company). We have fixed the issue by using a separate Octopus variable for the subject name now.