Select Page

Apache + PHP + OpenSSL

I’ve been trying to write a web based certificate authority to help make signing up for my OpenVPN installation easier for the users. Till now we used OpenVPN GUI for WIndows that provides a frontend to SSL for creating the CSR’s. It’s all a pain and way beyond what our users can manage in general so a nice web front-end is called for.
I read that PHP has bindings to the OpenSSL libraries so I thought I’d try and use that. I had endless hassles with Apache though, it would just die the moment I call the openssl_* functions in PHP or things would just return FALSE without any useful errors. I tried this on 4 FreeBSD machines all with Apache 1.x on, eventually I found it worked fine on Apache 2 machines! Upgraded one of the systems and it’s all good now.
Writing the SSL stuff is very simple with PHP, I’ll soon have a full implementation of a Certificate Authority done that is fully web driven so if there are any interest in this I may clean it up and release it under some Open Source licence, will also put up some code samples later but for now just wanted to point out that to get this stuff going you need Apache 2 it seems, well at least on FreeBSD machines.
The full entry has some screenshots of where I am today with the CA so you can get an idea of what I am getting at.

(more…)

This weeks photoblog shots

Here are the shots I liked this week on the photoblogs I read, only a handful really, for some or other reason I had some trouble finding ones that really impressed me.
Revenge of The Cranes
moma moments II
Hoop
Coney Island VII
Wet Patio
Tower Bridge at sunset
Quite a few sunset pics this week, but I have to say Revenge of The Cranes is by far my favorite.
So while on the subject of sunsets, here is one I took in Venice, this is obviously photoshopped, I applied a Diffuse Glow to it which is one of the few editing methods that significantly change an imagine that I use, I especially like it on sunsets.


Venice Sunset

One For All Mosaic on the XBox

I bought a One For All Mosaic aka URC-9990 universal remote control to try and make sense of the mess of remote controls on my table.
Primary concern was compatibility with the xbox specifically to use with XBox Media Center (XBMC). The remote itself is nice enough, UI leaves a bit to be desired during the setup stage but I guess you can’t have it all in a ยฃ40 remote.
Getting stuff going in the XBox though was another story, the Mosaic has a internet download function that plays a WAV file through your speaker into its microphone, bit like a 300 baud modem without any handshaking or carrier. I downloaded their XBOX profile this got the basics going but since the actual XBox remote control lacks volume, mute etc these were not added.
The Mosaic has a learn function like most of these remote controls I guess but I am sure there is a limited capacity for learned codes so I wanted to not use these if at all possible. It also has a Key Magic system that lets you enter codes manually, the hassle though is that they have obfuscated the codes and what actually gets sent. They say the Key Magic thing is patented etc and you need to speak to their customer support to get the right Magic key to your remote codes. Well thats just b/s all it is is a lookup against one set of numbers that will output the real number out via IR. IR only has 255 valid signals so its not that difficult.
I set the XBMC into debug mode where it shows the IR signals it receives and so made a table of Key Magic codes to actual codes, I also put in what default codes are in use on the XBox remote controller. View the full entry for the table of codes. It was actually very easy there are easily detectible patterns in their mapping from Magic codes to actual codes.
XBMC has in its latest version a global volume control that can be activated in all screens, it also has short cuts for accessing Videos, Movies, Weather and so forth, all accessible by the remote if you know the codes and can program it correctly. The keymap.xml defines what happens when keys or IR signals gets sent. The definition for the global volume up is:

<action>
<description>volumeup</description>
<id>88</id>
<gamepad>rightthumbstickup</gamepad>
<remote>volumeplus</remote>
<keyboard>+</keyboard>
</action>

Simple stuff, so to activate the volume button on the Mosaic I simply assigned a Magic Key using the table below and put the actual value that the Magic Key sends in the keymap.xml like this:

<action>
<description>volumeup</description>
<id>88</id>
<gamepad>rightthumbstickup</gamepad>
<remote></remote>
<remotecode>129</remotecode>
<keyboard>+</keyboard>
</action>

Notice that I cleared out the <remote></remote> blocks and added the <remotecode></remotecode> ones. Actual code 129 maps to Magic Key 262. Using the same simple procedure I also added quick access keys for movies and music and activate the mute button.
I am not sure why One For All feel they need to obfuscate something so fundamental to the operation of the remote control, but I hope this helps you use the device you paid good money for without having to waste additional money and time by having to call or mail them.

(more…)

Applescript

The windows world never really got into scripting GUI applications. You get your Visual Basic for Applications in the MS Office tools (and some others), other big apps have their own scripting languages or simple macro languages but it really is a mess since these things pretty much all do their own thing.

Apple has for ages had Applescript. Applescript is a single scripting language that can script any GUI application – as long as the GUI app makes some commands available but most do.

The nice thing about Applescripts is that the runtime requirement is satisfied on all Apple computers even from the old Classic ones. Things have changed a bit but its remained the same basic thing for a long time. The language is very english like and pretty simple to learn, I’ve read a book on the plane back from Helsinki and pretty much jumped right in and wrote something useful.

I use NetNewsWire 2 which is really all you’d want in a RSS aggregator. Specifically I sync all my subscriptions via Bloglines and just subscribe to them in NetNewsWire. The problem is when you do that you do not end up with the same groups or custom names as you have in Bloglines so it is a pain to restructure it all when you need to resubscribe to all your feeds.

So once I did the initial big job of putting all feeds into categories and renaming some – specifically I rename personal blogs to the name of the person rather than whatever people call their blogs – I wanted to export my subscriptions to OPML as a backup. NetNewsWire has a function for this but unfortunately it does not export any Bloglines feeds! Totally useless to me then. Applescript to the rescue.

I will not go through the whole app here, you can get the complete source a bit later, but here are just some snippets and a few words on each to show the basics of scripting with Applescript.

First we tell our script to speak to NetNewsWire and fetch all the group folders.

tell application "NetNewsWire"
repeat with curGroup in (every subscription whose is group is true)
end repeat
end tell

The whose is group is true reads a bit weird, ‘is group’ is a boolean property of each subscription, so the above will loop over all the groups thats been defined.

Next we want to pull out each subscription for the group we are in, so we grow the code to look like this:

tell application "NetNewsWire"
repeat with curGroup in (every subscription whose is group is true)
set t to display name of curGroup
-- put code here to build outline entries for each group
repeat with curSub in (every subscription whose display name of group is t)
-- put code here to build outline entries for each sub in this group
end repeat
end repeat
end tell

Here I get the display name property of the current group and search for all subscriptions with the same group.

After building the opml file and storing it in a variable I simply chose to output a new TextEdit.app document with the contents of the opml file, but could easily have written a new text file for example

tell application "TextEdit"
activate
make new document
set the text of the front document to opml as Unicode text
end tell

Simple stuff, start up the TextEdit application, make it active, create a new document and put the opml file contents into the document as Unicode Text.

So that’s the basic logic, you can get the full script here. This will probably not work 100% with nested groups and I do not cater for subscriptions that does not belong to any group, it works for me though ๐Ÿ™‚

This is a simple example but it does demonstrate though the absolute beauty of this, data from one app written by one software house queried and modified then output into an app written by another all by a scripting language written by a 3rd, fantastic.