OAuth Certificate Authentication with ACS

Summarises our experience authenticating callers with the Windows Azure AppFabric Access Control Service (ACS) using X.509 certificates.

Here’s the scenario. A consumer (Alice) wants to publish a message to the Azure AppFabric Service Bus, however before doing so, somehow needs to prove that she is in fact Alice. Taking a certificate based approach, requires Alice to craft a SAML token which among other things states “i’m Alice” (relying party scope), and signing this token with Alice’s (private key) certificate. If Alice were to deliver this token to ACS (https://yournamespace.accesscontrol.windows.net/v2/OAuth2-13), and a relying party, rule group and service identity with Alice’s public key had been configured, ACS in return would give Alice another token (a SWT token by default) signed with a specified signing key, which Alice could use from that point to prove identity.

In short, we are providing a token, with the intent of receiving another token in return. The token returned by ACS is potentially very powerful, and can be used to authorise access to resources in many downstream systems.

To establish this relationship between ACS and consumers, consumers need to have an X.509 certificate that uniquely represents them as the consumer. A self signed (makecert.exe) certificate in this instance is perfectly fine. Next the public key for this certificate needs to be exported (.cer) and provided to the ACS administrator. It’s important to note here that the private key (.pfx exports contain both the private and public keys) portion of the certificate should always be kept confidential. ACS only requires a consumers’ public key in order to verify their digital signature.

The OAuth sample in the OAuth2 folder for the Access Control Service Samples and Documentation contains many gems for doing this. Such as crafting SAML2 tokens, and populating the necessary OAuth HTTP headers, and so on.

This sample illustrates how to authenticate to Windows Azure AppFabric Access Control Service (ACS) using the OAuth 2.0 protocol by presenting a SAML token signed by an X.509 certificate. This certificate corresponds to a ServiceIdentity configured on ACS, and ACS issues a SWT with a nameidentifier claim of the ServiceIdentity. This SWT is used to authenticate to an OAuth 2.0 protected resource. This sample conforms to draft 13 of the OAuth 2.0 protocol.

When doing this for the first time, or when things don’t work out, its awesome to be able to inspect the HTTP conversations that take place with ACS. As you would expect, ACS enforces the use of SSL. SSL tunnels present a huge problem in terms of tracing. Fiddler fortunately comes to the rescue. Fiddler works by placing itself as a man-in-the-middle proxy between the client and server, as a result it also needs to provide a certificate for SSL requests. As this is not recognized as valid certificate, .NET throws an WebException at System.Net.HttpWebRequest.GetResponse() and no traffic shows up in Fiddler. To still be able to check accuracy of the programmatic requests with Fiddler, it is possible to directly add a new delegate, which always returns true, basically disabling certificate validation from deep within the framework libraries.

To get up and running with Fiddler and SSL tracing:

- Tools > Fiddler Options > HTTPS > Decrypt HTTPS Traffic

- Add this line of code to the .NET code responsible for transmitting the SAML token to ACS :

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

First attempt to run the code, I got a simple HTTP 400 back. Fiddler showed the following.

    HTTP/1.1 400 Bad Request
    Cache-Control: private
    Content-Type: application/json; charset=utf-8
    Server: Microsoft-IIS/7.0
    Set-Cookie: ASP.NET_SessionId=mxla1kuojr1udh0u2sho21i0; path=/; HttpOnly
    X-AspNetMvc-Version: 2.0
    x-ms-request-id: 8718c3e7-a3ee-4cf0-af1f-951a09dfd9fe
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    X-Content-Type-Options: nosniff
    Date: Mon, 24 Oct 2011 05:27:12 GMT
    Content-Length: 1113

    {"error":"invalid_grant","error_description":"ACS50008: SAML token is invalid. ACS50006: Unable to verify token signature. The following signing key identifier does not match any valid registered keys: SecurityKeyIdentifier\r\n    (\r\n    IsReadOnly = False,\r\n    Count = 1,\r\n    Clause[0] = X509RawDataKeyIdentifierClause(RawData = RAW_DATA_GOES_HERE)\r\n    )\r\n. \r\nTrace ID: 8718c3e7-a3ee-4cf0-af1f-951a09dfd9fe\r\nTimestamp: 2011-10-24 05:27:13Z"}

ACS50006: Unable to verify token signature. The following signing key identifier does not match any valid registered keys. The error message spells it out. ACS could not find ANY valid certificates. Using the ACS Management Portal, go to Service identities, and drill into the identity of concern. If the status of the certificate is anything but valid (e.g. because its expired, etc) you will get this error. The certificates provided for the OAuth2 sample in the Access Control Service Samples (16 May 2011 update) all expired as of 16 Sep 2011, and will result in this exact error.

expired.cert

 

To get the samples working, I created my own self signed certificates.

makecert -r -pe -n "CN=mexia" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -ss My

I then exported the public key portion (.cer) of the certificate, using the certificate manager MMC snap-in (certmgr.msc).

export.public.key

 

Using the ACS Management Portal, upload the exported “.cer” against the service identity.

If everything lined up, you should get a HTTP 200 containing a SWT token in return from ACS. An essence, a rather elegant alternative to using shared secrets to figure out who’s who.

    HTTP/1.1 200 OK
    Cache-Control: public, no-store, max-age=0
    Content-Type: application/json; charset=utf-8
    Expires: Mon, 24 Oct 2011 06:03:44 GMT
    Last-Modified: Mon, 24 Oct 2011 06:03:44 GMT
    Vary: *
    Server: Microsoft-IIS/7.0
    Set-Cookie: ASP.NET_SessionId=qz0cuqmk1nxt01wxehbqvq25; path=/; HttpOnly
    X-AspNetMvc-Version: 2.0
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    X-Content-Type-Options: nosniff
    Date: Mon, 24 Oct 2011 06:03:45 GMT
    Content-Length: 606

    {"access_token":"http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=OAuth2SampleX509Identity&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fbensimmonds.accesscontrol.windows.net%2f&Audience=https%3a%2f%2foauth2RelyingParty%2f&ExpiresOn=1319439825&Issuer=https%3a%2f%2fbensimmonds.accesscontrol.windows.net%2f&HMACSHA256=uaSF%2fojN%2f4SBQd5p1IYurRu0B5hc6Pdz4uC9ChvqFE4%3d","token_type":"http://schemas.xmlsoap.org/ws/2009/11/swt-token-profile-1.0","expires_in":"3600","scope":"https://oauth2RelyingParty/"}

 

 

As an aside, the following error response was returned from ACS when using a self-signed certificate created with makecert using the following switches:

makecert -n "CN=mexia" -pe -ss my -sr LocalMachine -sky exchange -m 96 -a sha1 -len 2048
    makecert -n "CN=benjaminify" -pe -ss my -sr LocalMachine -sky exchange -m 96 -a sha1 -len 2048

    HTTP/1.1 400 Bad Request
    Cache-Control: private
    Content-Type: application/json; charset=utf-8
    Server: Microsoft-IIS/7.0
    Set-Cookie: ASP.NET_SessionId=hxi2tbkn404lihcndxnuka35; path=/; HttpOnly
    X-AspNetMvc-Version: 2.0
    x-ms-request-id: 00dc92c8-9a72-4f0f-8b38-c5581a5cfcc5
    X-AspNet-Version: 4.0.30319
    X-Powered-By: ASP.NET
    X-Content-Type-Options: nosniff
    Date: Mon, 24 Oct 2011 05:56:55 GMT
    Content-Length: 286

    {"error":"invalid_grant","error_description":"ACS50008: SAML token is invalid. ACS50017: The certificate with subject \u0027CN=benjaminify\u0027 and issuer \u0027CN=Root Agency\u0027 failed validation. \r\nTrace ID: 00dc92c8-9a72-4f0f-8b38-c5581a5cfcc5\r\nTimestamp: 2011-10-24 05:56:55Z"}

Unlike the above working example, this will create a self-signed certificate associated with a issuer called “Root Agency”. ACS will spit the dummy (ACS50017) if the root issuer cannot be verified/trusted.

Posted in Azure, Windows Azure AppFabric | 1 Comment

Mexia Welcomes Ben Simmonds into the Fold

We are extremely happy to announce that Ben Simmonds has started with Mexia today, based in Canberra as a Senior Integration Specialist focused on building hybrid integration platforms using BizTalk Server and the Azure AppFabric Middleware stack.

He is an extremely bright and talented young developer, whose passion for technology shows through in every conversation you have with him.

Ben represents Mexia’s first permanent member of staff to be based in Canberra, and will help build a team of like-minded integration specialists that work with our Federal Government clients with their integration platform needs.

You can get in touch with Ben directly on bens@mexia.com.au or get him on Twitter at @benjaminify.

Welcome aboard mate, we’re very happy to have you!

Posted in Mexia | Leave a comment

Mexia Enters the Next Phase of Our Growth

Mexia was founded in 2008 with a vision to provide specialist architectural & technical consulting services in enterprise integration, with a laser-focus on Microsoft BizTalk Server and Windows Server AppFabric.  Obviously that focus has now extended to include the fantastic new capabilities of the Azure AppFabric Middleware Services, but as a business we are still committed to excellence in purely system integration and business process automation.

However being good at technology and being good in business are two very different beasts, and after starting in 2008 it took me a while to realise that I would need some help on the business side of things.

In early 2009 I was introduced to iLab in Toowong, Queensland, which is a Queensland State Government-funded business incubator that “…turns technology start-ups into successful global ventures”.

iLab

In exchange for an extremely modest monthly fee with no long-tem obligations, I was introduced to the exciting, challenging, potentially complex world of entrepreneurialism.

iLab has several fantastic good things going for it: CEO briefings, networking, introductions to solicitors & accountants, sales training, cheap co-location office space etc etc.  But by far and away the best thing that iLab offered me was the once-a-month Mentor Meetings with a panel of successful entrepreneurs who volunteer their time to help the next generation of young guns to come up through the ranks.

When Mexia joined iLab I had a mentor panel hand-picked for me, with their real world experience being evaluated against the range of experience & skills that I would be needing access to.  This service alone was worth it’s weight in gold.

The Mentor Meetings are run every month like a real Board Meeting where, apart from grilling me on financial performance, strategy, market positioning, HR strategy etc, they teach you how to walk & talk like a grown-up company. 

I’ve said it once and I’ll say it again until I’m blue in the face – if you’re new to business get yourself some mentors!

Mexia has been part of the iLab incubator program now for 2.5 years, and as a business I don’t know where we’d be without them.  They’ve nurtured and supported me whilst I went through the journey from complete novice to (mostly)competent businessman, and have ensured that Mexia now has the strategic & operational foundations from which we will surely grow & succeed in the marketplace.

Since 2008 Mexia has grown from just me and a laptop, to having:

  • 7 full-time staff (and counting)
  • clients in almost every state in Australia
  • an amazing business partner (Mathew Coleman)
  • a formal Board of Directors, and
  • a crystal clear vision of who we are, what we do, and where we’re going.

However, as in life all good things must come to an end, and we’ve decided it’s time for Mexia to ‘graduate’ from iLab and move out into the real world.  We’ve grown up, and just like our kids, we need to move out of home.

So yesterday I had my final iLab Mentor Meeting, and as usual it was an intense, challenging, rewarding and fulfilling experience.

photo

If it wasn’t for these guys sitting around the table Mexia would not be the quickly-growing company that it is today.

From left to right around the table:

  • Chris Tia
  • Andrew Campbell
  • Calvin Treacy (and the Chairman of Mexia’s new Board of Directors)
  • David Clarke
  • Paul Watts
  • Mathew Coleman (my new business partner & Mexia’s National Projects Director)

NB: I’d also like to say a special thanks to Colin Kinner, Anne-Marie Birkill, Peter Allison, Michael Good and Helen Vince for for their respective roles in Mexia’s time at iLab.

 

Just like you can’t tell someone what it’s like to have kids until you’ve had them, you can’t tell someone what it’s like to start & grow a business until you’ve lived through the emotional stress-coaster yourself.  These guys “get it”, and we have a bond forged through a shared appreciation of having to make payroll every fortnight with never enough money in the bank :-)

So this post is an indulgent THANK YOU from me to my iLab Mentor Panel.  It’s been a privilege to have you all pick apart my (our) business every month.  I feel sad today for the end of this fabulous process, but I also feel so incredibly proud!

Posted in Mexia | 5 Comments

Issues with Tracking causing high CPU usage on BizTalk SQL Server

As part of our regular BizTalk Health Check service that we do for a client, we had an issue where the CPU usage on the BizTalk SQL Server kept increasing over the past few months. I looked at all the usual culprits for this increase in CPU usage on the SQL Server but none of those seemed to be the cause. I started looking a bit deeper into the BizTalkMsgBoxDb with the help of MsgBoxViewer and found that the tracking data from the trackingdata_1_X tables was not being moved to the DTA database. I then checked to make sure that the tracking host was running and it was, it then became a bit more puzzling, the trackingdata_0_X tables were being move to the BAMPrimaryImport, so part of the tracking was working.

After speaking some more with the client, they mentioned that they had run the BizTalk Message Box clean-up stored procedure (knowing it was unsupported in production) more than once in the past year, and the problem was getting worse in the last couple of months.  I then started digging a bit deeper into exactly how the tracking data gets moved from the BizTalkMsgBoxDb to the BizTalkDTADb and found that there is a table in the BizTalkDTADb that keeps track of the last Sequence Number moved from the BizTalkMsgBoxDb tracking_1_X table to the BizTalkDTADb. I then looked at the current number in this table (TDDS_StreamStatus) and they were not even close to the Sequence Numbers in the trackingdata_1_X table in the BizTalkMsgBoxDb.

After fixing this Sequence Number mismatch the tracking data started to move as expected and over the next hour or so the CPU usage on the BizTalk SQL server dropped significantly low and back to what I would have expected on a BizTalk system with this amount of load.

The tools that can be used to fix these sort of issues it the BTSTerminator and it can be found along with other BizTalk Tools here: http://msdn.microsoft.com/en-us/biztalk/dd920317.aspx

Posted in BizTalk | Leave a comment

Brisbane BizTalk User Group–Wed 29th Sept

This is just a quick reminder about the next Brisbane BizTalk User Group being held Wednesday 29th Sept.

There will be two talks for the night:

1.  Geoff Clarke (Integration Specialist, Microsoft) will talk about the Future of BizTalk.

2.  Dean Robertson (Technical Director, Mexia) will demonstrate the awesome simplicity of Azure ServiceBus Queues & Topics.

Register here http://briztalk.org/ and I hope to see you there.

Posted in BizTalk, Mexia | Leave a comment

BizTalk Server 2010 Training in Adelaide – 24-28th October

Mexia is partnering with Academy IT in Adelaide again to deliver another BizTalk Server 2010 Development training event from 24th – 28th of October.

The BizTalk Server 2010 Developer Training is an update version of the existing BizTalk training that now includes WCF send and receive adapter, a BizTalk Patterns module (correlation, sequential convoy and parallel convoy) and optional EDI components. The course is targeted at beginning BizTalk developers, or developers that want to bring their skills up to 2010.

If you have any question, or want to discuss your BizTalk training needs, please contact us at training@mexia.com.au or AcademyIT directly.

Posted in BizTalk, Training | Leave a comment

A Conceptual Understanding of Azure AppFabric ServiceBus Topics

I’ve been digging into the latest (Sept v1.5) release of Azure AppFabric ServiceBus recently and got caught up on some really simple (in hindsight) concepts that initially had me confused.

Being a BizTalk Server guy I was naturally trying to draw parallels with the pub-sub architecture of that product. This diagram from Paolo Salvatori’s blog post is as good as I’ve seen anywhere on all the moving parts involved in the Azure ServiceBus Topics, and with my annotations below in the curly brackets I managed to see how it relates conceptually to BizTalk.

 

Untitled

 

So based on this “ah-ha” moment I wanted to post my simple explanations in the hope it might help someone else learning this new platform.

Here are some simple definitions that I have found useful when designing solutions that use the new Azure AppFabric ServiceBus topics:

  • A topic is an Azure ServiceBus entity (that you define) to which clients publish their messages, based on the topic of conversation between any number of publishers and subscribers.  i.e. “SupplierInvoices”
  • The published message must be wrapped in the Microsoft.ServiceBus.Messaging.BrokeredMessage type before it gets sent to the topic, and can be any serialisable object you choose to send.  However the clients need to be able to deserialise & use the message, thus should know what to expect will be coming off the wire.  So the data type should be related to the “topic” of conversation. i.e.”InvoiceType”.
  • A subscription is like a pigeon-hole on the other end of the topic.  A copy of each and every message published to the topic is given to each and every subscription that’s been defined, and it is up to the subscription to execute it’s own rules to decide whether or not it will accept it.  i.e. “InvoicesFromNewSuppliers” and “InvoicesFromExistingSuppliers”
  • Message properties are a collection [IDictionary<String, Object>] of metadata values that can be populated by the publishing client.  These property values are used by the subscription rules to decide whether to accept the topic message or not. i.e. SupplierStatus = “New” or “SupplierStatus = “Existing”
  • A subscription rule has both a filter and action, and is the mechanism by why the subscription decides whether it wants to allow its copy of the topic message into it’s pigeonhole for clients to ultimately receive. i.e. the “InvoicesFromNewSuppliers” subscription would have the following rule filter expression “WHERE SupplierStatus = ‘New’”

There is obviously a LOT more complexity to the platform than the above simplistic definitions would suggest. However when explaining it to clients it helps to start with the basic concepts first.

Cheers,

Dean

NB: This obviously isn’t an “intro to” post. Try here and here for that type of information.

Posted in Azure, Windows Azure AppFabric | Leave a comment

Our TechEd 2011 Talk

The TechEd Australia 2011 talk that Bill Chesnut and I did a few weeks back has been put online for those that couldn’t make it.

It’s always interesting to hear yourself back and realise what you actually said vs. what you think you remember saying Smile

Posted in Azure, BizTalk | Leave a comment

Welcome Mathew!

Mexia has rolled out the red carpet this week for Mathew Coleman, our new National Projects Director based out of our equally new Melbourne office location!

http://au.linkedin.com/in/mathewcoleman

https://twitter.com/#!/Mat_Coleman

With 12 years industry experience across both Tier-1 consulting firms, banking & financial services clients, he’s got some seriously strong Microsoft Application Platform implementation expertise.

Specifically Mat’s role will entail:

  • working directly with our clients to ensure their BizTalk & Azure Middleware projects are always a success;
  • working with our technical team to ensure we deliver on-time and on-budget;
  • continually refining our implementation methodology to ensure we execute our day to day activities with purpose;
  • growing the Melbourne office so we’re even better placed to work with our Victorian clients; and most importantly
  • ensuring that when a client chooses to use BizTalk Server, they have a trusted partner they can rely on throughout the journey.

When I started Mexia back in 2008 I always knew that I’d eventually need someone like Mat to help me run the business.  He’s always been the benchmark in my mind of what a good delivery specialist looks like, and to actually have him now as part of the management team is both an honour and an exciting milestone in the growth of our business.

Onwards and upwards!

Posted in Mexia | 1 Comment

Bill Chesnut Speaking at Adelaide Dot Net Users Group next Wednesday night (Wednesday 10th August 2011)

While I am in Adelaide next week delivering a BizTalk 2010 Developer Training course, I have been invited to speak at the Adelaide Dot Net Users Group.

My talk will be: BizTalk and the Cloud, Can the kids play together?

We will have a look at what is new in BizTalk Server 2010 and then look at how BizTalk to leverage some of the new feature of Windows Azure to make Enterprise Integration easier.

To get more information or to register for the meeting go to: http://tinyurl.com/yjqsnjw

Posted in Azure, BizTalk | Leave a comment