Corrupted stream detected malformed integer

Hi Octopus Support,

One of our developers is receiving the below error: “corrupted stream detected malformed integer” when trying to deploy to TEST (this is a DEV-TEST-PROD lifecycle). I’ve deleted the release and created a new one from Octopus (it’s pulling the same package), and it succeeds deploying to DEV, but always fails at TEST.


FULL EXCEPTION:

Octopus v2019.3.5

corrupted stream detected
Org.BouncyCastle.Asn1.Asn1Exception
at Org.BouncyCastle.Asn1.Asn1InputStream.ReadObject()
at Org.BouncyCastle.Asn1.Asn1InputStream.BuildEncodableVector()
at Org.BouncyCastle.Asn1.Asn1InputStream.CreateDerSequence(DefiniteLengthInputStream dIn)
at Org.BouncyCastle.Asn1.Asn1InputStream.ReadObject()
at Org.BouncyCastle.Asn1.Asn1Object.FromByteArray(Byte[] data)
at Org.BouncyCastle.Security.PrivateKeyFactory.CreateKey(PrivateKeyInfo keyInfo)
at Org.BouncyCastle.Pkcs.Pkcs12Store.LoadKeyBag(PrivateKeyInfo privKeyInfo, Asn1Set bagAttributes)
at Org.BouncyCastle.Pkcs.Pkcs12Store.LoadPkcs8ShroudedKeyBag(EncryptedPrivateKeyInfo encPrivKeyInfo, Asn1Set bagAttributes, Char[] password, Boolean wrongPkcs12Zero)
at Org.BouncyCastle.Pkcs.Pkcs12Store.Load(Stream input, Char[] password)
at Octopus.Core.Certificates.CertificateParser.ReadPfx(Byte[] rawCert, String password)
at Octopus.Core.Model.Certificate.<.ctor>b__6_0()
at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue()
at Octopus.Core.Model.Certificate.ExpandVariable(VariableDeclaration variable)
at Octopus.Server.Orchestration.ServerTasks.Deploy.Manifest.DeploymentManifestFactory.ExpandTypedVariables(VariableCollection variables, IEnumerable1 variableExpanders) at Octopus.Server.Orchestration.ServerTasks.Deploy.Manifest.DeploymentManifestFactory.CreateManifestVariables(String[] listenPrefixes, Deployment deployment, Project project, DeploymentProcess process, DeploymentEnvironment environment, Release release, Channel channel, ServerTask task, IList1 environmentAccounts, RetentionPeriod tentacleRetentionPeriod, ProjectGroup projectGroup, User initiator, VariableCollection projectVariables, VariableCollection libraryVariables, Release previousRelease, Release previousReleaseForEnvironment, Deployment previousSuccessfulEnvironmentDeployment, Release currentReleaseForEnvironment, Tenant tenant, Space space, ICanonicalTagNameMapper tagNameMapper, VariableCollection tenantVariables, IActionTemplateVersionFinder actionTemplateVersionFinder, ICollection1 certificates, ICollection1 accounts)
at Octopus.Server.Orchestration.ServerTasks.Deploy.DeploymentFactory.CreateDeployment(IOctopusQueryExecutor transaction, Deployment deployment, User user, DateTimeOffset queueTime, Nullable1 queueTimeExpiry, ILifecycleProgressionEvaluator lifecycleProgressionEvaluator, ILifecycleService lifecycleService, IDeploymentSummaryService deploymentSummaryService, IDictionary2 additionalVariables, Func3 promptedVariableProvider) at Octopus.Server.Web.Api.Actions.DeploymentCreateAction.CreateDeployment(DeploymentResource resource, Release release, Project project, DateTimeOffset queueTime, Boolean isScheduledDeployment, User user, Func3 promptedVariableProvider, IDictionary2 additionalVariables) at Octopus.Server.Web.Api.Actions.DeploymentCreateAction.ExecuteRegistered() at Octopus.Server.Web.Infrastructure.Api.Responder1.Respond(TDescriptor options, NancyContext context)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at Octopus.Server.Web.Infrastructure.OctopusNancyModule.<>c__DisplayClass14_0.<get_Routes>b__1(Object x)
at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)

–Inner Exception–
malformed integer
System.ArgumentException
at Org.BouncyCastle.Asn1.DerInteger…ctor(Byte[] bytes)
at Org.BouncyCastle.Asn1.Asn1InputStream.CreatePrimitiveDerObject(Int32 tagNo, DefiniteLengthInputStream defIn, Byte[][] tmpBuffers)
at Org.BouncyCastle.Asn1.Asn1InputStream.ReadObject()

Hi @DocOck

Sorry that you’ve run into problems here.

Looking at the stack trace it seems that we are failing on trying to read a certificate, are you able to check if you have a cert that is scoped to Test for this project? For reference, this error indicates that the certificate has non-compliant DER values, which is why our certificate library (bouncycastle) is erroring out like it is.

We did make some improvements with bouncycastle in 2019.3.6, so it’s possible that an upgrade might help, but at this stage the error indicates an invalid certificate being the cause.

Let me know if there is anything else I can help with!

Regards
Alex

Thank you for clarifying this error, Alex. We’re working with the developer now on those certs.

No problems, happy to help if there’s anything we can do.

Regards
Alex