Monday, 21 December 2009

Error javax.net.ssl.SSLHandshakeException

So the time has come to move your new E-Commerce store out of the sand box and into the real world. In order to do this you need to buy an SSL certificate and install it on your server to get everything working.

So you bought your nice new SSL certificate and installed it on your server and you can view your chosen secure url in your browser using the normal https prefix. So everything is working.

Yet when you look in the integration console in Google Checkout you see the following error

We encountered an error trying to access your server at https://yourdomain.cm -- the error we got is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

So why is it not working in Google Checkout but works in my browser? and Why cant it find my SSL certificate?

The reason why Google Checkout is failing is simple. When you use your browser to point at a secure url with the normal https prefix the browser is clever enough to do a bit of detective work to find the location of your actual SSL certificate and the issuing authority. However a direct connection, in this case the Google Checkout API, is not.

Put simply if you are experiencing the above problem, it means that you need an extra step in place to install a certificate between your browser request and your actual SSL certificate. This is known as an intermediate certificate, and this joins the dots between your actual server SSL certificate and the issuing authority.

Why Does This Happen? And How Can I Fix It?

The main reason for this error is that your have purchased your SSL certificate from a third party, that is not directly from an issuing authority such as Verisign. This means that in order to correctly identify your certificate your need to install the intermediate certificate.

You should receive both your main SSL certificate (the one you need to install in your web server) and your intermediate certificate (the one you need to install on your server which is running your web server) from your third paty supplier, if you did not get back on to them to get them reissued. Then once you have both simply install your main SSL certificate on the domain you wish to secure and install the intermediate on your server.

Thats it problem solved

NOTE - If you bought your SSL certificate directly from an issuing authority you should not have the above problem, as your server should already be aware of their existence.



Thanks
Sean J Connolly
Visit AJAX Web Development Store






BuzzProperties.co.uk - Online Property Sales and Letting



Thursday, 31 July 2008

How to check Google Checkout API has reached your callback page

In this post I will tell you how to find out if Google has actually reached your callback page, when using the Google Checkout Api.

There are several ways to check that Google is actually getting to your page.

1. Go into the Tools tab, then click on the integration console.

This will tell you if there are any errors that Google encountered trying to get to or run your page.

2. The next best way is to create a test event on your callback page that will fire when ever the page is run. This can be as simple as just writing a line to a text file, in fact using a text write is a good idea as you can write out all responses from Google and make sure are know which information is coming back, and whether it is correct or not.

A sample for this would be as follows

If you write the following into your callback page, a text will be written to a text file, if there is nothing written, Google has not run this page.

Sample 1 - Writing a simple line to a text file

Writes test line to TestFile.txt - TestFile.txt must exist in the same location on your server as you callback page, simple write the code below at the top of your callback page. If nothing is written Google has not reached your page, check the integration console as advised above.

'START OF CODE'

Dim fso, f, FilePath
Set fso = CreateObject("Scripting.FileSystemObject")
FilePath = Server.MapPath(".") & "\TestFile.txt"
Set f = fso2.CreateTextFile(FilePath, True)
f.WriteLine "Testing"

f.close

'END OF CODE'

Sample 2 - Writing Full Google XML response to text file

The following code will write the Google response to a text file called CompleteGoogleResponse.txt, which must exist in the same location as your callback page.

With this code you have two options, you can write it just below the LogMessage ResponseXML line in the sample callback.asp code provided by Google, just remove the last PrivateData and GNum lines.

or you can write it as is into the function called ProcessNewOrderNotification just write the code at the top of this function, and if all is well you will have a file with the full response XML from Google as well as your Google Order Number for this transaction and any private data your may have sent (NOTE remove the private data line if you do not send any in your original transaction), again if nothing is written Google failed to reach your page, check the integration console as advised above.

'START OF CODE'

Dim fso1, f1, FilePath1
Set fso1 = CreateObject("Scripting.FileSystemObject")
FilePath1 = Server.MapPath(".") & "\CompleteGoogleResponse.txt"
Set f1 = fso2.CreateTextFile(FilePath1, True)
f1.WriteLine "GoogleResponse=" & ResponseXml
f1.WriteLine "PrivateData=" & MyPrivateData.xml
f1.WriteLine "GNum=" & GoogleOrderNumber

f1.close

'END OF CODE'

NOTE

It must be said that if the above code is written into your callback page, and the text written to your file is something like GNum= but there is no information after the = sign, then Google has successfully hit your page, but failed to send you any information. Check the integration console as advised above.

I hope this makes sense, if you have any questions or want me to expand on any of this just drop me a comment or send me an email.

Thanks
Sean J Connolly
Visit AJAX Web Development Store




DMS - Document Management, Webmail
BuzzProperties.co.uk - Online Property Sales and Letting

Thursday, 22 May 2008

Google Search API Results

You may be custom to using the Google APIs for adding to your website or web application. I thought I would write a bit about why the results are not the same as the live Google system.

The 2 main API's that are used by developers from the Google network are the Map API and the search API, although there are other APIs in the Google arsenal, the Google Map API and Google Search API are 2 that return data.

The main question that I get asked is "Why do I get different results from using the API than that I do from using Google?".

The answer is mainly a two fold problem.

1. The issue with the API that relies on third party data, such as the Google Maps API, as most of the data Google uses for this API is not actually owned by Google. This is particularly true when it comes to the geo-coding, that is taken specific address information and turning into actual latitude and longitude on the planet for the Google Map to find. The main issue with this is that Google relies on purchased data to achieve this tasks, and in each country this is normally the postal services in that country.

This mean s that there are restrictions on what Google can do with this data, this is the main reason why when using the Google Map API you get different results than the actual Google Maps website, the Google Maps website data is different from the Google Maps API, just because of the restrictions placed on Google by licensees / owners of the data.

I know Google is working to improve the relationships and use of the data, so lets hope they can open up the world and the data in it.

2. The next issue other than licensing of the data is where the data comes from, this mainly fits with the Google Search API, as the Google search network is main up of different data centres, all of which have slightly different data. So you may get different results due to a different data centre being used, and as google route to data is different from a search on the Google website to using the Google Search API then the results can often be different.

It must also be pointed out that as a rtegisterd Google user Google remembers what you search for and improves your results, so when you use the Google website to search your results will be improved for a better match to what your looking for. However when you use the Google Search API this is not true, as the API returns raw data.

So I think that although we can use the Google APIs to build a mini Google world, it will never be the same as Google. Which makes sense after all the great guys and gals at Google allows us to use most things for FREE, so keep this in mind when coding. Look at what you are trying to do and ask yourself what you really want to do.

Thanks
Sean J Connolly
Visit AJAX Web Development Store





NotJustAJAX - Techy Blog
DMS - Document Management, Webmail
BuzzProperties.co.uk - Online Property Sales and Letting