I had to deal with this but with jpgs. Here is the code I use which works really well. It should be easy to adapt for a png.
// To get an image with basic auth, you can't use the normal CPURLConnection & CPImage way.
// You must manually build an XMLHttpRequest with auth header, override the response mime type,
// and process the responseText to base64. Then make a CPImage from that.
var xhr = new XMLHttpRequest();
xhr.open('GET', SBWC_SERVER_URL + encodeURIComponent(scene_id) + "/" + encodeURIComponent(pictureName), true);
xhr.overrideMimeType('text/plain; charset=x-user-defined');
xhr.setRequestHeader("Authorization", "Basic " + SBWC_BASIC_AUTH);
xhr.onload = function(e) {
var binary = '';
for (var i = 0; i < xhr.responseText.length; i++) {
binary += String.fromCharCode(xhr.responseText.charCodeAt(i) & 0xff);
}
picture = [[CPImage alloc] initWithContentsOfFile:"data:image/jpg;base64," + window.btoa(binary)];
[picture setDelegate:self]; // CPImageView gets it's image set in CPImage imageDidLoad delegate callback.
};
xhr.send();