Code Monkey home page Code Monkey logo

codesigning-demo's Introduction

CodeSigning Demo

Build Status

A demo project containing an example .Net Core class library. The Azure Pipeline steps build the project and signs a specific DLL using a code signing certificate that was stored in Azure Key Vault.

Background

Code signing certificates need to be stored at FIPS 140-2 Level 2 or above. A common solution is using a USB token but that makes CI/CD automation difficult if build agents are cloud hosted.

This demo takes advantage of Azure Key Vault which uses FIPS 140-2 Level 2 validated HSMs to store the certificate and then utilise it in an Azure Pipeline.

Overview of the build

  • Build the project
    • This should use --out to send resulting DLLs elsewhere.
  • Download the PFX from KeyVault
    • The secretsFilter is set to the name of the code signing certificate, so only the certificate is downloaded
    • The name of the Key Vault and SecretsFilter are secret variables set in the definition
    • The property azureSubscription is the AzureRM Service Connection name which needs to be created. This isn't a secret variable.
  • Turn the code signing certificate into a .pfx
    • The powershell script saves the certificate to the file system and creates a build variable called pfxOutLocation with the location of the .pfx on the filesystem.
    • Secrets downloaded from Key Vault using the AzureKeyVault Azure Pipelines task are passed as a Base64 encoded string. This means they cannot be used directly to sign code and needs to be saved to the filesystem first as a .pfx
    • The password mapped is a secret variable set in the definition. This is the password that will be set for the .pfx when it is saved to the filesystem.
  • Sign a single binary
    • Uses the SignTool to sign, using SHA1. You can use alternative methods for signing and should use SHA256.
    • As this is only a demo, we only sign a single binary.
    • The password mapped for this step is the same as used in the previous step. The password is used by the sign tool to access the certificate.
  • Publish to inspect the signed DLL
  • Delete the PFX to ensure it doesn't remain on disk.

Dependencies

  • An Azure KeyVault containing the Code Signing Certificate
  • An AzureRM Service Connection in Azure Pipelines. The Service Principal used must have at least read access to the Azure KeyVault.

Getting the certificate into Azure KeyVault

The basic process is to create the private key and CSR in Azure KeyVault, then use the CSR to generate the certificate through your Certificate Authority. The resulting certificate can then be uploaded to Azure KeyVault.

We used GlobalSign our as CA, not all allow this approach.

Links

codesigning-demo's People

Contributors

alexander-hjelm avatar marcdenman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.