Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void ConfigureServices(IServiceCollection services)
options.ManifestFileName = "asset-manifest.json";
options.Host = "192.167.1.100";
options.Port = 8081;
opts.Scheme = "https";
options.Scheme = "https";
});
// ...
}
Expand Down
3 changes: 2 additions & 1 deletion samples/WebApp/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path');
const path = require('path');
const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
Expand All @@ -19,6 +19,7 @@ const config = {
},
devServer: {
port: 8080,
https: false,
contentBase: false,
compress: true,
quiet: false,
Expand Down
5 changes: 5 additions & 0 deletions src/Webpack.AspNetCore/DevServer/DevServerOptions.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@ public DevServerOptions()
/// Scheme. Default: http
/// </summary>
public string Scheme { get; set; } = "http";

/// <summary>
/// Toggle server certificate validation if <see cref="Scheme"/> is 'https'
/// </summary>
public bool ValidateServerCert { get; set; } = true;
}
}
9 changes: 7 additions & 2 deletions src/Webpack.AspNetCore/DevServer/Internal/DevServerBackchannelFactory.cs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;

namespace Webpack.AspNetCore.DevServer.Internal
Expand All @@ -16,9 +16,14 @@ public DevServerBackchannelFactory(DevServerBackchannelFactoryContext context)
this.context = context ?? throw new ArgumentNullException(nameof(context));
}

public HttpClient Create(Uri baseAddress)
public HttpClient Create(Uri baseAddress, bool validateCert)
{
var handler = context.GetMessageHandler();

// We don't always want to validate when connecting locally. This is only for dev anyways, right?
if (!validateCert)
handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, certChain, policyErrors) => true;

return new HttpClient(handler, disposeHandler: false)
{
BaseAddress = baseAddress
Expand Down
6 changes: 3 additions & 3 deletions src/Webpack.AspNetCore/DevServer/Internal/DevServerBackchannelFactoryContext.cs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net.Http;
using System.Net.Http;

namespace Webpack.AspNetCore.DevServer.Internal
{
Expand All @@ -20,10 +20,10 @@ public DevServerBackchannelFactoryContext()
{
AllowAutoRedirect = false,
UseCookies = false,
UseProxy = false
UseProxy = false,
};
}

public HttpMessageHandler GetMessageHandler() => handlerInstance;
public HttpClientHandler GetMessageHandler() => handlerInstance;
}
}
4 changes: 2 additions & 2 deletions src/Webpack.AspNetCore/DevServer/Internal/DevServerManifestReader.cs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand Down Expand Up @@ -37,7 +37,7 @@ public DevServerManifestReader(DevServerContext context, DevServerBackchannelFac
throw new ArgumentNullException(nameof(backchannelFactory));
}

backchannel = backchannelFactory.Create(context.ManifestUri);
backchannel = backchannelFactory.Create(context.ManifestUri, context.Options.ValidateServerCert);
backchannel.DefaultRequestHeaders.Add("Connection", "keep-alive");
}

Expand Down
4 changes: 2 additions & 2 deletions src/Webpack.AspNetCore/DevServer/Internal/DevServerReverseProxyMiddleware.cs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using System;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -33,7 +33,7 @@ public DevServerReverseProxyMiddleware(

this.next = next ?? throw new ArgumentNullException(nameof(next));
this.devServerHost = context.DevServerHost;
this.backchannel = backchannelFactory.Create(context.DevServerUri);
this.backchannel = backchannelFactory.Create(context.DevServerUri, context.Options.ValidateServerCert);
}

public async Task Invoke(HttpContext context, DevServerAssetPathRepository repository)
Expand Down