Archiv für die Kategorie ‘English’

Slippery When Wet #3: IIS Certification Authority Cache

Sonntag, 25. April 2010

I proudly present to you the third in a infinite number of posts of “Slippery When Wet.” In these posts I show you a little bastard I stumbled on.

For an Web Application I needed not only to check the user rights but also to limit the the allowed computers. For this I limited the access with a client certificate that has to be installed on the accessing computer.
At the beginning I used a free client certificate from Thawte, as the server certificate was also from them. This certificate was only valid for one year. So I had to renew this certificate every year and all allowed computers had to be updated.
But as Thawte ended their support for the free certificate I needed an other solution. I chose to use a self signed certificate as the client certificate but keep the server certificate from Thawte as on the server were also running other Web Applications that needed https.
So I created the Certification Authority (CA) certificate and a client certificate signed with this CA certificate with openssl. Testing with this certificates worked as it should. But for Testing purposes I used the default values for the validity length. So I created a new CA and a new client certificate with a longer validity period. After removing the testing certificates and installing the new created certificates I thought it will work as before, but the client certificate was not selectable in the client certificate selection dialog of internet explorer.
I tried several things like restarting IE, clearing the SSL cache and cursing. But nothing helped.
Analyzing the communication between client and server with openssl brought the solution: The Internet Information Server (IIS) was still using the old, already removed CA certificate, probably from his cache, but not the new one, maybe because the were named similar. After restarting the IIS on the server the new client certificate was selectable in the client certificate selection dialog of internet explorer.
Conclusion: After removing a (CA) Certificate from the IIS restart it to clear the cache!

Syntax Highlighting with Plugin

Montag, 05. April 2010

I’ve added today the plugin CodeColorer to provide syntax highlighting to the source code blocks in my blog. The plugin is based on the GeSHi – Generic Syntax Highlighter library.
The old articles have been updated to use the new plugin

HTC TyTN Factory Reset

Montag, 27. April 2009

As this Information is no more available on the HTC Website I store them here for me and everybody that needs this information:

Hold both soft keys (the two keys that represent the options on the screen), push the reset button with the stylus and keep the two keys until the screen shows the options to continue the operation.

Warning: All data (contacts, sms, installed software, pictures etc) wil be ereased!

Get the password of user IWAM_

Samstag, 17. Januar 2009

After trying some things in the IIS settings I wanted to change back to use the IWAM_* account. But for this I needed the password. I’ve searched and found some informations and tips to get the password that was used for the IUSR_* or IWAM_* accounts.

Slippery When Wet #2: SCOPE_IDENTITY and SqlDataReader

Samstag, 25. Oktober 2008

I proudly present to you the second in a infinite number of posts of “Slippery When Wet.” In these posts I show you a little bastard I stubled on.

Imagine you have a database table with a cloumn id of the data type integer that has set the IDENTITY. You use a stored procedure to insert a new entry into this table. Inside this stored procedure you use the SCOPE_IDENTITY() function to get the identifier created for this row. With RETURN SCOPE_IDENTITY() you give the identity to the caller.

You call this stored procedure from a SqlComand with ExecuteReader() that returns you an SqlDataReader object.

From this SqlDataReader you read now the identifier with GetInt32().

Wrong !

This will give you an InvalidCastException. SCOPE_IDENTITY()’s return type is numeric, although your identifier column is an integer. SqlDataReader’s GetXY functions do not convert the data and throw the exception when the data is not already of the right type.

The first solution

You can read the value with GetDecimal() and cast the value to an int:

int identifier = (int)reader.GetDecimal(0);

The second solution

You cast the identifier inside the stored procedure und return it already as an integer:

SELECT CAST(SCOPE_IDENTITY() AS int)

Whatever solution you choose, take care that you use always the same inside your application.

Slippery When Wet #1: Javascript’s GetMonth()

Samstag, 11. Oktober 2008

I proudly present to you the first in a infinite number of posts of “Slippery When Wet.” In these posts I show you a little bastard I stubled on.

I had to reformat a date in Javascript. There were all this little nice functions of a date object like

getFullYear(), getHours(), getMinutes()

and also

getMonth()

. Every of these functions returned the value as it would also be shown, but not getMonth(). getMonth() returns a value from 0 to 11, so 0 is January, 1 is February and so on untill 11, that is December.

I see a possible reason for this: With values from 0 to 11 you can use the value directly as the index for an array with the month names inside, like

alert(months[myDate.getMonth()]);

no update for database row if parameter is null

Freitag, 03. Oktober 2008

Sometimes you want write a stored procedure to update a database entry, but you want be able to leave some columns unchanged. If you don’t need to set them back to null you can use the following code:

UPDATE TABLE
  SET Column1 = ISNULL(@parameter1, Column1), Column2 = ISNULL(@parameter2, Column2)
  WHERE PrimaryKey = @KEY

The command ISNULL uses the first parameter, if it is not null, or the second parameter if the first is null. When you pass a value, this value is used, but when you pass null the current value of this column is used, so it overwrites it with the same value.

The Open Software Wiki – SWiK

Mittwoch, 20. August 2008

Found the Open Software Wiki – SWiK on the internet. Let’s see how it evolves.

Exception after sending data async from a thread

Samstag, 24. Mai 2008

If you have a situation like this:

void MyThreadFunc()
{
// do some work

socket.BeginSend(buffer, 0, buffer.Length, 0, new AsyncCallback(MyCallback), s);
}

void MyCallback(IAsyncResult ar)
{
Socket s = (Socket) ar.AsyncState;
s.EndSend(ar);
}

And you send a big buffer over a slow connection it can happen that calling EndSend() will throw a SocketException ‘The I/O operation has been aborted because of either a thread exit or an application request’.

This happens because the Thread that started the sending is no more available when the sending ends. The only solution I know is to make sure the thread is still available or to use syncronous sending if possible.

WordPress aktualisiert / Worpress updated

Samstag, 05. April 2008

Heute habe ich endlich WordPress auf Version 2.5 aktualisiert.
Today i’ve updated WordPress to the Version 2.5.