6

@home Web サーバーで SSL にhttps://github.com/ebekker/ACMESharpを使用しています (無料です! :O)。それはかなり手動でしたが、wiki で、SSL の申請、ダウンロード、およびインストールを自動化するための GUI であるhttps://github.com/Lone-Coder/letsencrypt-win-simpleの別のプロジェクトについて言及していることに気付きました。 cert を Web サーバーに追加します。

[webroot]/.well-known/[randomFile]ドメインがあなたのものであることを検証するために GUI が使用する方法は、拡張子のないテキストのランダムな文字列を含むランダムな名前のファイルを作成することです。この [webroot] で実行されている .dotnetcore アプリケーションでは、IIS で「ハンドラー マッピング」を変更するための指示に従った後でも、ファイルを提供できません。

でファイルに直接移動することでファイルを提供できるようです[webRoot]/wwwroot/[whatever]-では、なぜ私はできないの[webroot]/.well-known/[randomFile]ですか?

誰でもこれを回避する方法を知っていますか? .netcore アプリを削除してから、SSL 証明書のインストールを実行できますが、このインストールは 2 ~ 3 か月ごとに行う必要があり、手動であるため、正しい方法を見つけたいと思います。

4

1 に答える 1

4

ここで必要な情報を見つけました: https://docs.asp.net/en/latest/fundamentals/static-files.html

基本的に私の Statup.cs で、これを変更する必要がありました:

        // allows for the direct browsing of files within the wwwroot folder
        app.UseStaticFiles();

        // MVC routes
        app.UseMvc(routes => 
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

これに:

        // allows for the direct browsing of files within the wwwroot folder
        app.UseStaticFiles();

        // Allow static files within the .well-known directory to allow for automatic SSL renewal
        app.UseStaticFiles(new StaticFileOptions()
        {
            ServeUnknownFileTypes = true, // this was needed as IIS would not serve extensionless URLs from the directory without it
            FileProvider = new PhysicalFileProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @".well-known")),
            RequestPath = new PathString("/.well-known")
        });

        // MVC routes
        app.UseMvc(routes => 
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

編集-このディレクトリ「.well-known」はWebサーバー上でのみ作成されたことに注意してください。ローカルで再度開発を開始すると、「.well-known」ディレクトリが存在しなかったためエラーが発生しました。これで、プロジェクトに空のディレクトリができましたが、少なくとも SSL の更新は自動化されています! :D

于 2016-07-16T00:49:38.773 に答える