2017-09-07 40 views
0

我已經使用IdentityServer4與asp網絡核心Web,在localhost:50481中調試時都工作正常,但是當我在同一臺計算機上使用myipaddress:50481並且調試模式時,它失敗。我不使用臨時證書,相反,我創建了一個RSA證書:Identityserver4不工作的IP地址

.AddSigningCredential(Config.GetSigningCertificate()) 

    public static RsaSecurityKey GetSigningCertificate() 
    { 
    var filename = Path.Combine(Directory.GetCurrentDirectory(), "certificateKey.rsa"); 

     if (File.Exists(filename)) 
     { 
      var keyFile = File.ReadAllText(filename); 
      var tempKey = JsonConvert.DeserializeObject<TemporaryRsaKey>(keyFile, new JsonSerializerSettings() { ContractResolver = new RsaKeyContractResolver() }); 

      return CreateRsaSecurityKey(tempKey.Parameters, tempKey.KeyId); 
     } 
     else 
     { 
      var key = CreateRsaSecurityKey(); 

      RSAParameters parameters; 

      if (key.Rsa != null) 
       parameters = key.Rsa.ExportParameters(includePrivateParameters: true); 
      else 
       parameters = key.Parameters; 

      var tempKey = new TemporaryRsaKey 
      { 
       Parameters = parameters, 
       KeyId = key.KeyId 
      }; 

      File.WriteAllText(filename, JsonConvert.SerializeObject(tempKey, new JsonSerializerSettings() { ContractResolver = new RsaKeyContractResolver() })); 

      return CreateRsaSecurityKey(tempKey.Parameters, tempKey.KeyId); 
     } 
    } 

我還檢查本地主機的ip地址,並在jwks,它們是匹配的。

當我將項目發佈到本地IIS時,localhost不起作用,出現500內部錯誤。

都在我的應用程序的URL是「http://localhost:50481

感謝您提前幫助。

回答

1

我不得不說這是一個愚蠢的錯誤,我沒有注意到authConfig,

let config; 

if (window.location.hostname === 'localhost') { 
    config = configForDevelopment; 
} else { 
    config = configForProduction; 
} 

當我使用的IP地址,配置的是切換到督促,localhost更改我的IP地址是有意義的。

希望可以別人。