Like many open source tools (originally or completely) based on Linux, git has issues with self-signed certificates, especially if you work in a corporate environment where your company may have network message inspection hardware for security. To get git to work in such an environment, you'll need the public root Certificate Authority certificate for your company, exported to a base 64 .cer file. Once you have that, run the following command to install it into git's private certificate store:
git config --global http.sslCAInfo "<path/to/your/certfile.cer or .pem>"
Showing posts with label certificate. Show all posts
Showing posts with label certificate. Show all posts
Tuesday, January 09, 2018
Wednesday, January 03, 2018
Using NodeJS with a corporate firewall that uses certificate interception
See this post on Stack Overflow. The gist of it:
1. Export your company's corporate Root CA certificate to a Base64 encoded .cer file
2. Run this command to instruct npm to use the certificate file in its communications:
1. Export your company's corporate Root CA certificate to a Base64 encoded .cer file
2. Run this command to instruct npm to use the certificate file in its communications:
npm config set cafile = "<path to your certificate file>"
Tuesday, September 06, 2016
Solving "m_safeCertContext is an invalid handle."
I've recently been trying to get an application working in Azure App Service that acts as a client who calls out to another service via WCF with TransportWithMessageCredential mode for security and Certificate mode for authentication. I've been getting the following error:
m_safeCertContext is an invalid handle.
According to this blog post, this error gets thrown when the certificate isn't correctly imported or has incorrect trust (for any of many possible reasons). Some of those reasons can include incorrect passwords, but there are others as well, like what I was encountering: in Azure App Service, there's no local user signed on when your application is running. Because of that, you run afoul of a subtle issue with managing certificates: all of the constructors, by default, use the user certificate store to temporarily store the PrivateKey of any loaded X509Certificate2 objects. Therefore, on an Azure App Service application, unless you use the new X509Certificate2(certBytes, passwordString, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable) constructor with the MachineKeySet | Exportable flags, your certificate will not be correctly read and will SILENTLY FAIL!!
m_safeCertContext is an invalid handle.
According to this blog post, this error gets thrown when the certificate isn't correctly imported or has incorrect trust (for any of many possible reasons). Some of those reasons can include incorrect passwords, but there are others as well, like what I was encountering: in Azure App Service, there's no local user signed on when your application is running. Because of that, you run afoul of a subtle issue with managing certificates: all of the constructors, by default, use the user certificate store to temporarily store the PrivateKey of any loaded X509Certificate2 objects. Therefore, on an Azure App Service application, unless you use the new X509Certificate2(certBytes, passwordString, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable) constructor with the MachineKeySet | Exportable flags, your certificate will not be correctly read and will SILENTLY FAIL!!
Friday, September 02, 2016
Solving 'The remote certificate is invalid according to the validation procedure' with WCF channels
This typically happens most often (when using certificates) when the certificate Common Name (CN) doesn't match the DNS host name of the server.
Wednesday, August 31, 2016
MSMQ, WCF and IIS: Getting them to play nice: The extras, Part I
I've recently been trying to set up queued publishing of data in my company within our internal applications so that we can publish that data out to other applications running in our hybrid cloud with Azure. To move the data around on-premise, I've been working off of the advice given to me by some very knowledgeable people in the IT space, and using architectural design patterns that have been proven to work (though not by me). To implement our new data-publishing architecture, I decided to leverage components I already had at my disposal and use WCF with MSMQ bindings to deal with unreliable connections from some of our remote sites. To help me get started, I began following the series of articles published here on MSDN by Tom Hollander. I was able to get past Part 1 of the tutorial without problem. I even needed the same architecture: a queued message client publishing to a service, via a queue hosted on a 3rd party system.
Part 2 however, securing the queue, proved to be a little bit harder, to the point where I needed to go to stackoverflow.com for help and posted this question. In the question, I kept running into an error when I tried to enable Transport security along with ActiveDirectory support. When I didn't enable ActiveDirectory support, I got a different error, with the code 0xC00E0030. Looking on the page for MSMQ queueing error codes on MSDN, I found that this error means that there was corrupted security data, somewhere. Here's what I had to do to resolve it:
Part 2 however, securing the queue, proved to be a little bit harder, to the point where I needed to go to stackoverflow.com for help and posted this question. In the question, I kept running into an error when I tried to enable Transport security along with ActiveDirectory support. When I didn't enable ActiveDirectory support, I got a different error, with the code 0xC00E0030. Looking on the page for MSMQ queueing error codes on MSDN, I found that this error means that there was corrupted security data, somewhere. Here's what I had to do to resolve it:
- In the EndpointAddress for my WCF binding, I had to add an extra parameter to the constructor for the EndpointIdentity of my binding: New EndpointAddress(queueUri, EndpointIdentity.CreateDnsIdentity(queueUri.Host))
- I had to gain access to the server where I was hosting my MSMQ Server, and gain full access to the Server itself: Computer Management -> Message Queueing -> Right-click -> Properties -> Security tab -> [my name] -> "Full Control"
- I had to re-register my own Internal Certificate for MSMQ on the server: [previous steps] -> User Certificate tab -> Internal Certificate section -> Renew....
After cleaning up the certificate and adding the endpoint, I was good to go, and I could now authenticate and send messages to the MSMQ server.
To be fair to Tom Hollander, he did say that there would be some extra specifics to getting Authentication working, and I guess these were mine. I have to send him a lot of thanks for going through what he did AND recording and publishing the steps. People like him make the world a better place.
Wednesday, April 08, 2015
Removing a certificate binding from a port in Windows
As many people don't know, in Windows certificates can be bound to ports for securing content transferred over those ports. IIS happens to be particularly negatively affected by this if another program has a certificate bound to a port that you want to use, e.g. 443 for serving web pages.
Use the information at the following page to find the certificate binding and delete it :
https://msdn.microsoft.com/en-us/library/ms733791(v=vs.110).aspx
The short version:
Find the port: netsh http show sslcert | grep -C 5 443
This command will show all the SSL certificates that are bound to ports on your machine.
Delete the port: netsh http delete sslcert ipport=0.0.0.0:443
This should help deal with some of the more annoying (and less verbose) errors when doing things like trying to configure WCF services to use SSL.
Use the information at the following page to find the certificate binding and delete it :
https://msdn.microsoft.com/en-us/library/ms733791(v=vs.110).aspx
The short version:
Find the port: netsh http show sslcert | grep -C 5 443
This command will show all the SSL certificates that are bound to ports on your machine.
Delete the port: netsh http delete sslcert ipport=0.0.0.0:443
This should help deal with some of the more annoying (and less verbose) errors when doing things like trying to configure WCF services to use SSL.
Saturday, August 09, 2014
Creating a certificate chain of self-signed certificates for development / testing / private environments
As anybody who's ever tried to develop secure services with SSL knows, it's expensive to buy trusted certificates from a certification authority. This is especially true if you're an independent developer who doesn't have a lot of resources. Therefore, we need to be able to generate self-signed certificates in order to develop and test our code before we actually go buy a Trusted Certificate for production. This tutorial will show you how to create a chain of trust and start generating certificates from a self-signing authority. The information here is based off of Microsoft's documentation on MSDN about the matter.
- Create a signing authority certificate:
- makecert -n "CN=My Signing Authority" -r -sv MySigningCert.pvk MySigningCert.cer
- Merge the private key file and public key file into an encrypted key (this isn't mentioned in the MSDN article linked above, but you can find the documentation here):
- pvk2pfx /pvk MySigningCert.pvk /spc MySigningCert.cer /pfx MySigningCert.pfx /pi mycertpassword /po mycertpassword /f
- Start creating site certificates with your signing certificate:
- makecert -iv MySigningCert.pvk -n "CN=www.mywebsite.com" -ic MySigningCert.cer -sv sitekey.pvk sitekey.cer -pe
You'll be prompted for passwords for securing the private key. Ensure that you remember them, you'll need them to create the merged file.
This step isn't necessary for signing site certificates, but does make things more convenient for storing the certificate and installing it on different machines. Be careful: you should never leave keys laying around file systems on machines, they should always either: a) be stored in an encrypted store like that provided by Windows, or b) be stored on separate storage media that can be physically locked away with access only available to trusted personnel.
Now, as above, I recommend that you merge the .pvk and .cer into a .pfx for easy transport and storage.
Labels:
cer,
certificate,
encryption,
makecert,
pfx,
pfx2pvk,
pvk,
self,
signing,
ssl
Thursday, June 26, 2014
Getting code signing to work with ClickOnce on a TFS Build Agent
Code signing is a giant pain in the butt. You have to :
- Obtain the certificate for signing the code by:
- buying the certificate from an issuer.
- generating your own self-signed certificate
- Configure ClickOnce within your project file with the following property elements:
- <signmanifests>true</signmanifes>
- <manifestcertificatethumbprint>A387B95104A9AC19230A123773C7347401CBDC69</manifestcertificatethprint>
- Log into your machine **as the user running the build controller / agents ** and import the key to their user Personal certificate store!
- Run 'certmgr.msc' from the Run command in the start menu (WinKey + R is the hotkey)
- In the Certificate Manager that comes up, go to Personal in the tree, right-click, and select All Tasks -> Import ...
- In the Certificate Import Wizard window that comes up, select Next to move to the 'File To Import' screen.
- Select your certificate file, which has the same thumbprint as specified in your project file, then click Next to move to the 'Certificate Store' screen.
- In the 'Certificate Store' screen, select the 'Place all certificates in the following store' option, then click Browse to select the store. Choose 'Personal' in the selection window. Click Next to move to the "Completing the Certificate Import Wizard" window.
- On the "Completing the Certificate Import Wizard" window that comes up, click Finish to import the certificate.
You should now be able to build and sign your code on a TFS Build controller / agent.
Labels:
agent,
build,
certificate,
clickonce,
code,
controller,
sign,
tfs,
thumbprint
Tuesday, September 24, 2013
Converting a .cer and .pvk to a .pfx file
The Windows SDK comes with a built-in tool for performing this conversion, the details of which you can find here. The command you'll need looks something like the following :
pvk2pfx /pvk MyCert.pvk /pi inputpassword /pfx MyCert.pfx /po outputpassword /spc MyCert.cer
pvk2pfx /pvk MyCert.pvk /pi inputpassword /pfx MyCert.pfx /po outputpassword /spc MyCert.cer
Subscribe to:
Posts (Atom)