Friday, 3 July 2015

SSL and ServiceStack

SSL and ServiceStack

Ok now I have my ServiceStack working with Android using the native ServiceStack client (AndroidServiceClient). I have now implemented SSL. I've opted for Self Signed Certs at the moment.

My current setup is:


Desktop->Cisco Router->Android

The desktop requires the Self Signed Certificate creating, I'm using SelfSSL.exe for the job.
C:\ssl>selfssl /N:CN=YourSerivceName /V:9999

C:\MMC
Then Add Snap-In Certificate Manager running under Local Machine.
Copy your  YourSerivceName cert to the Trusted Root Certification Authorities

C:\netsh http add sslcert ipport=0.0.0.0:xxxx appid={yyyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyy} certhash=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Where:
xxxx is the listening SSL port
{yyyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyy}  is the the assembky guid from AssemblyInfo.cs in your ServiceStack application.

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz is the Thumbprint from your YourSerivceName certificate.

In may case the to allow port xxxx through on my desktop firewall.
On my cisco router I have forward the port:
ip nat inside source static tcp desktop.pc.address xxxx my.wan.addreess xxxx extendable

Then allow the port to be accessible on the inbound rule
access-list aaa permit tcp any host my.wan.address eq xxxx

To test the port is open, start your ServiceStack application
new AppHost().Init().Start("https://+:xxxx/");
then use a free online port checking tool to see if all in ok. I use ww.yougetsignal.com/tools/open_ports/  

Congratulations you created a ServiceStack SSL service! 
 

Wednesday, 1 July 2015

AndroidServiceClient with Authentication

I'm currently researching ServiceStack as a replacement to my own services for handling REST between Android and Windows.

I've got the client (Android) working using loopj's AsyncHttpClient. But I was looking for a more native library. Initially I was using Jsonserviceclient but decided on the AndroidServiceClient. The problem I had was setting up basic authentication on the connection. After a few hours of reading JsonServiceClient.java (which AndroidServiceClient extends). It transpired I have to implement my own request ConnectionFilter and set uo the request headers in the void exec(HttpURLConnection urlConnection) method.

After creating code I got the error "cannot set request property after connection is made".
Seems I needed to tweak the code to suppress this error.

CustomRequestFilter...
package com.jjoplc.pod.Views;

import android.util.Base64;
import net.servicestack.client.ConnectionFilter;
import java.net.HttpURLConnection;

/**
 * Created by norm on 01/07/2015.
 */
public class CustomRequestFilter implements ConnectionFilter {

    private String password = "";
    private String username = "";

    static  boolean done = false;
    public void exec(HttpURLConnection urlConnection) {
        if (done) {
            done = false;
            return;
        };

        done = true;

        String credentials = username + ":" + password;
        final String basicAuth = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP);
        urlConnection.setRequestProperty("Authorization", basicAuth);
    }

    public void setUsername(String userName) {
        this.username = userName;
    }

    public void setPassword(String passWord) {
        this.password = passWord;
    }
}



Set up.


 _androidClient = new AndroidServiceClient("http://myservice:8088");
_requestFilter = new CustomRequestFilter();
_requestFilter.setUsername("User");
_requestFilter.setPassword("Password");
_androidClient.RequestFilter = _requestFilter;


And Test.


androidClient.getAsync(new dto.Hello().setName("Normski"), new AsyncResult<dto.HelloResponse>() {
    @Override
    public void success(dto.HelloResponse r) {
        view.setText(r.getResult());
    }

    @Override
    public void error(Exception ex) {
        view.setText(ex.toString());
    }
});

Friday, 13 February 2015

Realtime Probing

We have a Cisco 3945E as our WAN router as a test to see if we are vulnerable I added realtime log of denied access on the access rule associated with our WAN connection. The results were quite interesting. Here map below shows IP addresses being mapped in realtime over a 5 minute period.

Friday, 3 October 2014

Data Visualization and WPF

 I've been working on data visualization technigques in my spare time. My current project is Sunburst chart. In the example below I'm mapping the first 2 level of folders on my disk. Clicking a directory 'segment' drill down into the selected segment.



Wednesday, 1 October 2014

email 2 SMS for Android

I've just developed a Email SMS App for Android.

To summarise; you configure you app to look at your email inbox. The App then polls the inbox looking for an email with a specific subject line that the app knows about. Once it sees an email with the matching subject line it then parses the email body or a known structure i.e. SMS-MESSAGE SMS-PIN SMS-CONTACT  etc. If it manages to parse the information it validates the Pin code with a known pin code configured in the App. If the pin code matches it then sends the message to the list of parsed SMS contacts.So basically it's uses your mobile phone as a SMS relay. I'll be publishing the the App on Googles Play Store in the very near future.

For more information please visit Email 2 SMS

Tuesday, 30 September 2014

This sums up man



Reading this article reminds of this video. When are humans going to control their own population?