Problem:
I was trying to export an SSL public/private key from IIS. This will export only as a pfx. I needed it as a base64 encoded file. This often happens with proxy servers which host a front end. They don't seem to like pfx since they all tend to run Linux.
Solution:
Create a console application and programmatically create the cert file.
m_X509CertificateThumbprint = Regex.Replace(rawThumbprintString, @"[^\u0000-\u007F]", string.Empty);
m_X509CertificateThumbprint = rawThumbprintString.Replace("\u200e", string.Empty).Replace("\u200f", string.Empty).Replace(" ", string.Empty);
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
//var certificate = store.Certificates.Find(X509FindType.FindByThumbprint,
// "69c04af8588ec65762de96ddd51d78fa6e47c692", false)[0]; // doesn't matter how you get the cert
var cert = store.Certificates.Find(X509FindType.FindByThumbprint, m_X509CertificateThumbprint, true);
if(cert.Count > 0)
{
X509Certificate2 full = cert[0];
Console.WriteLine(full.FriendlyName);
var exported = full.Export(X509ContentType.Pfx, "1qaz@WSX");
var base64 = Convert.ToBase64String(exported);
System.IO.File.WriteAllText(@"C:\viper\aeitt.cer.txt", base64);
}
store.Close();
Source:
http://stackoverflow.com/questions/8863785/how-to-get-the-base-64-encoded-value-of-a-certificate-with-private-key
http://stackoverflow.com/questions/11115511/how-to-find-certificate-by-its-thumbprint-in-c-sharp
This missive records my trials and tribulations as I code my way through projects. Fix the problem once and reuse the solution!
Thursday, October 29, 2015
Tuesday, October 27, 2015
Export SSL cert with private key from IIS 7.5
Problem:
Need to get the cert off of an old IIS box before it is decommissioned.
Solution: You will export the certificate and private key using the MMC console
1. Click start > run
2. Type MMC and click OK
3. Click on File > Add/Remove Snap-in…
4. Select Certificates and click Add
5. Select Computer Account, click Next
6. Leave Local Computer selected, click Finish
7. Click Ok / Close
8. You will be back at the MMC console and it will show the Certificates Snap-In
9. Expand Certificates, expand Personal, click Certificates
10. Right click your certificate > All Tasks > Export
11. Certificate Export Wizard will appear, click Next
12. Select “Yes, export the private key” > Next
13. Select “Personal Information Exchange – PKCS #12 (.PFX)”
14. Leave the checkboxes below unchecked.
Note: If you select “include all certificates…” then it will export the intermediate certificates as well, the problem is when you import them it will import the intermediate certificates into the personal store and not the intermediate store. So it’s best to manually import your intermediate certs following the steps from your cert provider.
15. Make up a password to secure the exported .pfx certificate file
16. Pick a location to save the exported .pfx certificate file > Save > Finish
Source:
http://enterpriseit.co/windows-server/exporting-ssl-certificate-pfx-from-windows-server-iis/
Need to get the cert off of an old IIS box before it is decommissioned.
Solution: You will export the certificate and private key using the MMC console
1. Click start > run
2. Type MMC and click OK
3. Click on File > Add/Remove Snap-in…
4. Select Certificates and click Add
5. Select Computer Account, click Next
6. Leave Local Computer selected, click Finish
7. Click Ok / Close
8. You will be back at the MMC console and it will show the Certificates Snap-In
9. Expand Certificates, expand Personal, click Certificates
10. Right click your certificate > All Tasks > Export
11. Certificate Export Wizard will appear, click Next
12. Select “Yes, export the private key” > Next
13. Select “Personal Information Exchange – PKCS #12 (.PFX)”
14. Leave the checkboxes below unchecked.
Note: If you select “include all certificates…” then it will export the intermediate certificates as well, the problem is when you import them it will import the intermediate certificates into the personal store and not the intermediate store. So it’s best to manually import your intermediate certs following the steps from your cert provider.
15. Make up a password to secure the exported .pfx certificate file
16. Pick a location to save the exported .pfx certificate file > Save > Finish
Source:
http://enterpriseit.co/windows-server/exporting-ssl-certificate-pfx-from-windows-server-iis/
Wednesday, October 21, 2015
HTTP Client PostAsync Fails in MonoTouch/iPhone
Problem:
Running tests on our cross platform solution and encountered an issue.
One step in our app sends an email out of the app using the HTTPClient libraries from MS. This is known to cause issues. I hit the boards stackoverflow, Xamarin, etc.. This is a fairly common problem. The crazy thing is that we are using this call in our pcl. It works with no issues on Android and Windows Phone. It is a problem on iOS. It appears to be a mapping issue in the PCL.
Solution:
James Montemagno did come up with a solution. The issue with the error was assembly binding error. The iOS version was binding to the native Windows System.Net.Http for .Net 4.5.
We should be binding to the Xamarin version which is at
C:\Program Files(x86)\Reference Assemblies\Microsoft\Framework\Xamain.iOS\v1.0
Why?
"The reason for the redirect is that the
You can fix this problem by modifying the app.config in the Touch project.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.5.0" />
</dependentAssembly>
</assemblyBinding>
Source:
http://stackoverflow.com/questions/27521738/httpclient-failing
https://github.com/Krumelur/HttpClientTest/blob/master/HttpClientTest_iOS/app.config
Running tests on our cross platform solution and encountered an issue.
I get an exception thrown on my call to postasjsonasync(). The exception says "A type load exception occured"
|
One step in our app sends an email out of the app using the HTTPClient libraries from MS. This is known to cause issues. I hit the boards stackoverflow, Xamarin, etc.. This is a fairly common problem. The crazy thing is that we are using this call in our pcl. It works with no issues on Android and Windows Phone. It is a problem on iOS. It appears to be a mapping issue in the PCL.
Solution:
James Montemagno did come up with a solution. The issue with the error was assembly binding error. The iOS version was binding to the native Windows System.Net.Http for .Net 4.5.
We should be binding to the Xamarin version which is at
C:\Program Files(x86)\Reference Assemblies\Microsoft\Framework\Xamain.iOS\v1.0
Why?
"The reason for the redirect is that the
Microsoft.Net.HttpClient
packages contains the System.Net.HttpClient
namespace but that already exists on iOS and Android (with slightly
different features even). At runtime it will resolve to the wrong
assembly and not use the (Xamarin-)native iOS one." (Thanks James!)You can fix this problem by modifying the app.config in the Touch project.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="2.0.5.0" />
</dependentAssembly>
</assemblyBinding>
Source:
http://stackoverflow.com/questions/27521738/httpclient-failing
https://github.com/Krumelur/HttpClientTest/blob/master/HttpClientTest_iOS/app.config
Monday, October 12, 2015
No exports were found that match the constraint: ContractName
Hit this today trying to load a project. Every project I fired up would throw this error when I tried to open any file!
Turns out that the issue is a corrupted cache. You just need to remove this directory
%AppData%\..\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
Source
http://stackoverflow.com/questions/17596543/error-message-no-exports-were-found-that-match-the-constraint-contract-name
Turns out that the issue is a corrupted cache. You just need to remove this directory
%AppData%\..\Local\Microsoft\VisualStudio\12.0\ComponentModelCache
Source
http://stackoverflow.com/questions/17596543/error-message-no-exports-were-found-that-match-the-constraint-contract-name
Friday, October 2, 2015
How to enable virtualization on HP Probook 6565 B
Step 1:
Get
CRM.vhd
Step 2:
Put
file on your c drive recommend c:\vm\crm.vhd
Step 3:
Tweak
your boot menu
a. Make a boot copy record
·
bcdedit /copy {default} /d "New
Name"
b. Get the GUID of the new boot
record
·
Bcdedit
·
Read
the GUID of your new record
c. Change the boot record to point
at your vhd file
·
bcdedit /set {GUID} osdevice
vhd=[C:]\folder\filename.vhd
·
bcdedit /set {GUID} device vhd=[C:]\folder\filename.vhd
·
bcdedit /set description
"Windows 10 VHD"
Step 4:
- Enable virtualization on your HP 6565
- Reboot your system and press F10
- Go to System Configuration Tab
- Scroll down to Virtualization Technology and check the box
- change BIOS Security Settings from View to Change for virtualization.
- Save changes to BIOS and exit
- Reboot
Step 5
When you reboot your will be
presented with the option of os to load.
Subscribe to:
Posts (Atom)