Salut,
Je suis coincée depuis 2 mois sur la mise en oeuvre d'un serveur web .net core 2.0 en https sur un serveur IIS et j'avoue que je suis complètement perdue.
D'après les documentations que j'ai trouvée, IIS doit être utilisé comme un reverse proxy ok, le truc c'est que je ne comprends pas comment on attache un nom de domaine à kestrel car toutes les doc parle de localhost, de port mais jamais de nom de domaine.
Dans mon cas,
Je suis sur un serveur windows server 2012 R2.
j'ai un domaine : ssl.mondomaine.xxx et j'ai créé un certificat ssl avec let's encrypt win simple. J'ai généré le pfx.
Le pool d'application est en mode aucun code managé, identité application pool identity.
- l'identité du pool a les droits Modif, lecture, execution
- IUSR, SERVICE RÉSEAU et SERVICE LOCAL lecture, exécution
J'ai positionné le pfx dans un dossier Cert à la racine du site.
La racine du site pointe à l'endroit du csproj (comme je le fais pour les site asp.net mvc 5).
J'ai créé un site asp.net core 2 mvc de base.
appsettings.json
launchSettings.json
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 { "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-CMS-50FB2AD1-3F9A-43AA-B6D5-5927EA39BB7A;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } } }
program.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 { "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { "applicationUrl": "http://localhost:52582/", "sslPort": 44367 } }, "profiles": { "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, "launchUrl": "https://localhost:44367/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, "SSL_Kestrel": { "commandName": "Project", "launchBrowser": true, "launchUrl": "https://localhost:5000/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://ssl.mondomaine.xxx/" } } }
startup.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 public static void Main(string[] args) { var config = new ConfigurationBuilder() .SetBasePath(basePath: Directory.GetCurrentDirectory()) .AddEnvironmentVariables(prefix: "ASPNETCORE_") .AddCommandLine(args) .Build(); var host = new WebHostBuilder() .UseKestrel() .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .UseSetting("applicationName", "SSL") .UseEnvironment("Development") .UseKestrel(options => { var certPath = Path.Combine(Directory.GetCurrentDirectory(), "Cert", "SSL.pfx"); options.Listen(IPAddress.Loopback, 5000); options.Listen(IPAddress.Any, 80); options.Listen(IPAddress.Loopback, 443, listenOptions => { listenOptions.UseHttps(certPath, "myPass"); }); }) .Build(); host.Run(); //<-- Error -4092 EACCES permission denied }
Je précise que le programme se lance sur le profil IISExpress mais lorsque j'essaye d'utiliser SSL_Kestrel j'ai l'erreur indiquée plus haut.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")) ); services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>() .AddDefaultTokenProviders(); // Add application services. services.AddTransient<IEmailSender, EmailSender>(); services .Configure<MvcOptions>(options => { options.Filters.Add(new RequireHttpsAttribute()); }) .AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } }
Pourriez-vous m'aider ?
Merci beaucoup !
Partager