Linux

Installing a SSL certificate in a LAMP environment

Wow, if you’re reading this you are doing so over a 256 bit encrypted link.  To give you an idea of what that means my bank only uses 128 bit encryption.  Now for a while I was doing this with a self signed certificate.  But then you run into all kinds of hassles that when you send a link to your non-geek friend they get all upset because they get a warning when they try to go to it.  Aside from that hassle (which I can live with) I ran into an issue with the flash uploader on my Gallery 3 site.  It seems that if you have a self signed certificate the flash uploader will not work leaving the only way to upload anything to the server was the ‘server add’ option that would have meant I whole bunch of work that I just didn’t feel like doing right now.

The Solution?  Get a signed certificate from a CA.  Yeah that seems a little obvious but here’s the thing.  I’m not selling anything meaning I’m not making anything and I don’t really want to pay for it.  Free SSL certificates?  Turns out yes they do exist.  I went with StartSSL and was very pleased with the experience.  The first thing I had to do was start by validating my email and getting a certification for that and then it was time to get the SSL/TLS Server cert.  Here is how I did it so I’ll know how to do it next time.

Telnet into the server and issue the following command:

openssl req -new -newkey rsa:2048 -nodes -keyout myserver.key -out server.csr

This will give you two files.
myserver.key: this is your encryption key.
server.csr: this is the Certificate Signing Request that you will submit to the CA

In my case (running Fedora Core 16) I placed the myserver.key file in the /etc/pki/tls/private/ directory.
When you submit it to the CA, they will have you cut and paste the returned text into a ssl.cert file. Get that onto your server and I put it in /etc/pki/tls/certs/. Then you need to find the ssl.conf file and change the SSLCertificateFile and SSLCertificateKeyFile file locations and names. Save the file, restart Apache and you are good to go.

UPDATE
Okay, got home and got a message that I missed a couple of files.  To this end let me say these are the files that were missing:

SSLCertificateChainFile /usr/local/apache/conf/sub.class1.server.ca.pem
SSLCACertificateFile /usr/local/apache/conf/ca.pem

I put them into /etc/pki/tls and just linked them in the ssl.conf and it worked fine and seemed to fix any issues I saw so don’t forget to do this next time.

Blogs/Blogging

New Code Highlighter

I had a devil of a time figuring out which syntax highlighter to install but I think that I finally found one that I am happy with.  It’s SyntaxHighlighter Evolved and I’ll be using it going forward.

C# SSIS

C# to move files in SSIS script task

Most of the time that I’m creating integration packages, I have a central working directory where all the action is taking place, at the end of the package execution is where I’ll archive files so that should they be needed to troubleshoot an issue I’ve got them in a handy place.  This is a script that I created for that process.  Note that lines 7 through 19 are generated by the Visual Studio Tools for Applications in SSIS when you create the script task.

using System;
using System.IO;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;

namespace ST_218640c1eafd4eb9ab909245d34e01c7.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{

#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion

public void Main()
{
string strOriginalFileName = @"C:\TCC\20110722-UpdateCandidate\UpdateHireEmpStatus.csv";
string strArchivedFileName;
string strDate;
DateTime dtDate = DateTime.Now;

strDate = String.Format("{0:yyyyMMdd_HH_mm_ss}", dtDate);

strArchivedFileName = @"C:\TCC\20110722-UpdateCandidate\Archive\UpdateHireEmpStatus-" + strDate + ".csv";

File.Move(strOriginalFileName, strArchivedFileName);
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
C#

C# to delete files older than X days from a directory

The vast majority of the time, when I build an integration I archive all the files so that they can be used to track down where something is going wrong.  Unfortunately if left unchecked these files can grow and grow and it becomes impossible (or rather terribly difficult) to sort through the files to see if there was indeed an issue.  The answer to this is to cull down the files when you archive them.  To this end it’s good to kill all files older than X days.  This is a console application that can do this, it actually does this in 3 directories.  Path, path1 and path2 define the directories and days is the amount of days back to delete.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TestConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string path, path2, path3;
int days;
System.DateTime date;
System.DateTime keepdate;
path = "Y:\\SQL_Backups\\SFDC_Data";
path2 = "Y:\\SQL_Backups\\TaleoData";
path3 = "Y:\\SQL_Backups\\dnn5_test";
days = 10;
date = (DateTime.Now);
keepdate = date.AddDays(-days);

DirectoryInfo fileListing = new DirectoryInfo(@path);

foreach (FileInfo f in fileListing.GetFiles())

{
if (f.LastWriteTime <= keepdate)
f.Delete();
}

DirectoryInfo fileListing2 = new DirectoryInfo(@path2);

foreach (FileInfo f in fileListing2.GetFiles())
{
if (f.LastWriteTime <= keepdate)
f.Delete();
}

DirectoryInfo fileListing3 = new DirectoryInfo(@path3);

foreach (FileInfo f in fileListing3.GetFiles())
{
if (f.LastWriteTime <= keepdate)
f.Delete();
}

}
}
}

I have yet to get this functionality to work in SSIS but will post how to do that once I figure it out.

Blogs/Blogging

Google Syntax Highlighter

Because I’m going to be using this site to store bits of information that happen to be code, I’ve decided to utilize Google syntax highlighter for this functionality.  The main problem is it’s pretty complicated to use.  So this post has the information I’ll need to use it.

The usage wiki for GSH can be found here and here is an example for the HTML:

Here’s a list of supported languages and their aliases:

Language Aliases
C++ cpp, c, c++
C# c#, c-sharp, csharp
CSS css
Delphi delphi, pascal
Java java
Java Script js, jscript, javascript
PHP php
Python py, python
Ruby rb, ruby, rails, ror
Sql sql
VB vb, vb.net
XML/HTML xml, html, xhtml, xslt
Blogs/Blogging

Welcome to the new blog

Hello, my latest attempt at a blog is here.  Got some updated hardware and a fresh install of Fedora Core 16 and the latest and greatest WordPress installed and away we go.  I’ll be using this blog to post bits and pieces of computer wisdom that I acquire in my day to day dealings as an integration engineer.  We’ll have a mix of transact SQL, some C# and Java along with some rather obscure details of dealing with TCC (Taleo connect client), data loader (the Salesforce.com integration engine) as well as SSIS.  Feel free to contact me if you have any questions or concerns.