Powershell: Enumerate and copy files from a network share
In Powershell 2.0 there is no real good way to copy files from a network share using alternate credentials. Since I have need to do this from time to time I wrote a couple of powershell functions which wrap around Wscript.Network. This helps keep (most) all of my Windows scripting inside Powershell.
.NET AnyCPU application running in 32 bit mode on 64 bit machine
At work we have a Continuous Integration system which builds every 15 minutes or so. While this helps us to quickly identify 'bad' code, at times it can lead to a false sense of security. I noticed this the other day when troubleshooting a bitness issue with one of my utilities.
On my Development machine I could build & test my exe in 64 bit mode. Once the code was built by the CI system it would only execute in 32 bit mode, which caused me problems when connecting to an Oracle server. I would get errors like this when trying to open a database connection:
Error: Could not load file or assembly 'Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.
at Vendor.DbCore.Oracle..ctor(String ConnectString)
at Vendor.DbConnectors.Oracle.Initialize(String RightsLocation)
Configure mod_rewrite + .htaccess for an Apache VirtualHost (Centos 6)
I've been playing around with PHP webservices recently. While getting one setup is fairly simple, they look kind of funny since you have to specify the /index.php component of the URL before any parameters. The index.php piece can be hidden if you use the apache webserver with mod_rewrite enabled.
To improve the flexibility of my development environment I decided to implement an .htaccess file to store the mod_rewrite rules in an Apache VitualHost. This article describes how to get mod_rewrite and htaccess files working inside a VirtualHost file.
Renew iOS Developer Certificate in XCode 4.3.2
I recently renewed my iOS Developer subscription with Apple. Just wanted to take a minute and note what steps I needed to follow to get my projects building with the new Developer identity:
- Renew Developer identity using XCode organizer window
- Open the XCode Organizer
- Go to the Devices tab
- Right Click on your iOS Device and select Add Device to Provisioning Portal
- Follow the wizard...
- You may see a message like this when you try to build:
- Code Sign error: Certificate identity 'iPhone Developer: Rion Carter (FFEEE55111)' appears more than once in the keychain. The codesign tool requires there only be one
- To resolve this issue I had to:
- Open the Keychain Access utility
- Find and delete the expired versions of the following:
- iPhone Developer: Developer Name (SomeID)
- iPhone Distribution: Developer Name
NOTE: Proceed with utmost caution. If you delete the wrong ones you are probably screwed. Take a backup first if you care about your identity at all
Note 2: I had to remove the old version from my 'old' keychain as well as my new one. This is becaue I changed Macs in the last year and migrated my old keychain forward. If you still get error messages about 'appears more than once' check your other keychains.
As compared to last year, this is a VERY simple process. It is all automated through the XCode UI and was quick and painless. It's not very often I say this but: Thank you, Apple, for making my life as an iOS developer a little less dreary.
Basics: Object Oriented PHP from a C# point of view
I've been slowly picking up PHP over the last 6 months or so to broaden my skillset. Up to now I've made procedural php pages and while that has worked it has felt a bit clunky. When I was asked to put together a simple LAMP stack to track GIT Hashes and map them to something similar to an SVN 'rev' I decided to dive head long into Object Oriented PHP. I did this for maintainability- this was for work, not some hacky page I put together on the side.
While things are still fresh in my mind I'd like to document what I had to do to get a simple class-based (Object Oriented) PHP project started from my perspective as a C# Developer (I spend most of my day in .NET land these days).
Updated: 27-July-2012
Delegates, Anonymous methods and Lambdas
In the past I'd always dismissed Anonymous methods and lambdas as needless syntactical sugar. After all 'Real' programmers are the ones who think in assembler, right? As time has worn on I can see that there is a lot to the .NET framework that I haven't fully explored and would like to get to know.
This article is here to help remind me of what I know about delegates help keep me in context as I learn the more esoteric parts of the .NET platform.
Bouncy Castle: Add a Subject Alternative Name when creating a Certificate
Bouncy Castle provides a way to assign a Subject Alternative Name while generating a certificate. Like most of the APIs, it can take a little getting used to.
This article shows a few ways not to generate SANs as well as some 'correct' code that helped me generate Alternate DNS Names for my test certificates
Bouncy Castle: Convert a BouncyCastle AsymmetricKeyEntry to a .NET AsymmetricAlgorithm
After extending my Certificate Generator tool to integrate directly with the Encryption Management product I work with I ran into a problem with converting private keys to a format that the .NET X509Certificate2 class could understand. .NET crypto does not 'like' the format Bouncy Castle uses to represent key data.
This is a case where better documentation for Bouncy Castle would have been great. I'm sure this must be a common issue.
Bouncy Castle: Create a Basic Certificate
Bouncy Castle is a pretty powerful cryptographic library. Unfortunately, one of its failings is a lack of proper documentation (Although there is a pretty comprehensive test project suite). As documentation is lacking, it can feel pretty good when you finally get Bouncy Castle to do something useful.
In this article I explain how to use Bouncy Castle (C# .NET variant) to create a simple certificate. For a source code example, please refer to my Certificate Generator tool (Certificate.cs)
For additional information on Bouncy Castle See these previous articles:
Bouncy Castle - what is it?
No, I'm not talking about the inflatable play castles. Bouncy Castle is an encryption library made available for Java and .NET platforms. I have run into it off and on over the last 4 years and recently implemented a Certificate Generator tool that uses the Bouncy Castle API for Key, Certificate and Keystore generation.
I'm getting back into it after being away for a year or so. Hopefully I'll have time to document some of the things I find this time around.