小编Mik*_*kel的帖子

IdentityServer4签名密钥,验证密钥和.Net Core数据保护

Identity Server 4文档(此处为http://docs.identityserver.io/en/latest/topics/crypto.html?highlight=data%20protection)讨论了签名密钥和验证密钥。我知道签名密钥是使用

AddSigningCredential(<X509Certificate2>)
Run Code Online (Sandbox Code Playgroud)

有两个用于验证密钥的API

AddValidationKey(<X509Certificate2>)
AddValidationKeys(<Microsoft.IdentityModel.Tokens.AsymmetricSecurityKey[]>) 
Run Code Online (Sandbox Code Playgroud)

该文档讨论了对密钥过渡进行签名并将多个验证密钥添加到发现文档中。问题-

identityserver4 asp.net-core-identity asp.net-core-2.0

5
推荐指数
1
解决办法
2025
查看次数

在订阅中捕获错误是不可能的吗?

我正在使用 Angular 7,我试图捕获抛出的错误,因为外部 api 返回的值在我期望的值处具有空值。

我似乎无法弄清楚在这种情况下我应该做什么。

我有一个调用 api 的服务。

getObjectValue(param: paramtype): Observable<ObjectValue> {
    return this.http.get<objectwithvalues>(environment.baseapiurl + '/api/object/value/'+ param);
  }
Run Code Online (Sandbox Code Playgroud)

在消费组件中,我像往常一样订阅

testfunction() {
   this.service.getObjectValue().Subscribe(v => {
    *DO STUFF*
    *Error happens* v['o'] // oh no v is null
   },
    error=>{
     console.log('error') 
     this.snackbar.open('this went wrong' + error); 
    }
  );
}
Run Code Online (Sandbox Code Playgroud)

这就是基本情况。这样做不会触发 'error=>{}' Angular 只是吐出一条错误消息。

所以我在订阅回调范围内尝试了 try/catch 。没抓到。

我目前正在尝试将服务代码更改为以下内容

getObjectValue(param: paramclass): Observable<ObjectValue> {
    return this.http.get<EventWifi>(
      environment.baseapiurl + '/api/object/value/'+ param).pipe(map(v=> {
   if(v === null){
     return throwError('v is null');  
   } 
  }),
   catchError(err => this.errorTest(err))
);
  } …
Run Code Online (Sandbox Code Playgroud)

error-handling try-catch observable rxjs angular

5
推荐指数
1
解决办法
4017
查看次数