mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Ignore SSL certificate errors for image URLs used in Image Editor..
This fixes issues with local development on SSL-enabled site with self-signed certificates. Ignoring certificate errors is usually not the wisest thing to do, but we're dealing with locally stored images here only.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ImageEditor.Models;
|
||||
@@ -98,14 +99,21 @@ namespace Orchard.ImageEditor.Controllers {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageMediaContent))
|
||||
return HttpNotFound();
|
||||
|
||||
var sslFailureCallback = new RemoteCertificateValidationCallback((o, cert, chain, errors) => true);
|
||||
|
||||
using (var wc = new WebClient()) {
|
||||
try {
|
||||
ServicePointManager.ServerCertificateValidationCallback += sslFailureCallback;
|
||||
|
||||
var data = wc.DownloadData(url);
|
||||
return new FileContentResult(data, "image");
|
||||
}
|
||||
catch {
|
||||
return HttpNotFound();
|
||||
}
|
||||
finally {
|
||||
ServicePointManager.ServerCertificateValidationCallback -= sslFailureCallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user