Problem: Reading a map into a BufferedImage using it's secure URL, then displaying it to the browser

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problem: Reading a map into a BufferedImage using it's secure URL, then displaying it to the browser

whereswaldo
From a servlet, my ultimate goal is to take several map layers, flatten them using a BufferedImage, then output that image to the user's browser.  Our clients want a way to save maps, displayed using OpenLayers, as JPEGs; the solution MUST work on IE and Firefox.  To simplify things, I attempted to display a single map; it works if I use an image using "http://...", but fails when using "https://..."

Here's the code:

        protected void doGet(HttpServletRequest request,
                        HttpServletResponse response) throws ServletException, IOException {


                URL zip_img_url = new URL("https://sum.address.com:8043/geoserver/wms?VERSION=1.1.0&WIDTH=16&HEIGHT=16&FORMAT=image/png"); // fails
                // URL zip_img_url = new URL("http://www.google.com/images/srpr/nav_logo39.png"); // works

                response.setContentType("image/png");
                BufferedImage zip_img = ImageIO.read(is);

                ImageIO.write(zip_img, "png", response.getOutputStream());
        }    

When I run this using the regular "http" URL, the image displays correctly.  If I use the "https" URL, then I get the following error:


        javax.imageio.IIOException: Can't get input stream from URL!
        ...
        sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        ...


Any ideas?  I'm pretty sure I'm missing some steps here.