I want my program to download tiles and open a map, as I click on the Tile I want to download, it gives me "The request was aborted: Could not create SSL/TLS secure channel" exception. It accepts and shows links like https://google.com eventhough it doesnt show the site itself it shows the way I want it to, black around and in the middle the Tile. I looked for alternatives like httpClient or RestSharp but none of them seems to work. It goes to the excepton from bytes = WebClient...etc So bytes stays Null.
try
{
System.Net.WebClient webClient = new System.Net.WebClient();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string blackTile = "X�V7��\u009da4�Sϥzu";
byte[] bytes;
int tries = 0;
do
{
tries++;
bytes = webClient.DownloadData("https://" + Request["server"] + ".tile.openstreetmap.de/tiles/osmde/" + Request["z"] + "/" + Request["x"] + "/" + Request["y"] + ".png");
if (Request["q"] != null && Request["q"] != "")
{
MemoryStream msIn = new MemoryStream(bytes);
MemoryStream msOut = new MemoryStream();
Bitmap bmp1 = new Bitmap(msIn);
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
EncoderParameters myEncoderParameters = new EncoderParameters(1);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, Convert.ToInt64(Request["q"]));
myEncoderParameters.Param[0] = myEncoderParameter;
bmp1.Save(msOut, jgpEncoder, myEncoderParameters);
bytes = msOut.ToArray();
}
} while (tries<=5 && System.Text.Encoding.Default.GetString(md5.ComputeHash(bytes)).Equals(blackTile));
HttpResponse response = Context.Response;
response.ContentType = "image/png";
response.AddHeader("title", "Bild");
response.OutputStream.Write(bytes, 0, bytes.Length);
}
catch (Exception ex) { }
}