Code signing custom builds¶
Code signing is an essential process for ensuring the authenticity and integrity of your custom Mattermost builds. This guide provides steps on how to code sign a build using your own certificates for Windows, Mac, and Linux.
Important
Make sure to follow each operating system’s guidelines and best practices for signing applications.
Prerequisites¶
- Code Signing Certificate: Obtain a certificate from a Certificate Authority (CA) or use a self-signed certificate if suitable. 
- SignTool: Available as part of the Windows SDK. 
- GPG Key: Create a GPG key if you don’t have one. 
- GnuPG: Install GnuPG if not already installed. 
- Developer ID Application Certificate: Obtain from Apple. It requires an Apple Developer account. 
- Xcode: Ensure Xcode is installed. 
Process¶
- Install SignTool: Install the Windows SDK to access the - SignToolutility.
- Obtain a Code Signing Certificate: Purchase or create a certificate ( - .pfxfile) via a CA.
- Import the Certificate: Open the - .pfxfile and import it into the Windows Certificate Store.
- Sign the Executable - Open the command prompt as Administrator. 
- Use - SignToolto sign your executable:
 - signtool sign /v /s "My" /sha1 <cert hash> /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 <path-to-your-executable> 
- Create or Import Your GPG Key: If you don’t have a GPG key, create one: - gpg --full-generate-key- Alternatively, import an existing GPG key, if you have one: - gpg --import /path/to/your-key.asc 
- Sign the Package: Use - dpkg-sigto sign a Debian package:- dpkg-sig --sign builder your-package.deb - Use - rpmsignto sign an RPM package:- rpmsign --addsign your-package.rpm 
- Verify the Signature: Verify the signature of a - .debpackage:- dpkg-sig --verify your-package.deb - Verify the signature of an - .rpmpackage:- rpm --checksig your-package.rpm 
- Obtain a Code Signing Certificate: Create a - Developer ID Applicationcertificate in your Apple Developer account and download it.
- Import the Certificate: Double-click the certificate to import it into the Keychain. 
- Sign the Application: Use the - codesigntool from Xcode to sign your application:- codesign --deep --force --verify --verbose --sign "Developer ID Application: Your Name (TeamID)" /path/to/your.app 
- [Optional] Verify the Signature: Verify the signature to ensure everything is correctly signed: - spctl --assess --verbose=4 /path/to/your.app codesign -dv --verbose=4 /path/to/your.app 
Summary¶
- Windows: Use - SignToolfrom the Windows SDK with your imported code signing certificate.
- Mac: Use - codesignand- spctltools from Xcode with your Apple Developer ID certificate.
- Linux: Use - GnuPGto create/sign with your GPG key,- dpkg-sigfor- .debpackages, and- rpmsignfor- .rpmpackages.
 
													 
													 
													 
													 
													 
													 
													