小编fli*_*ode的帖子

PowerShell使用密码PFX文件获取证书指纹

我正在尝试使用以下代码获取受密码保护的pfx文件的指纹:

function Get-CertificateThumbprint {
    # 
    # This will return a certificate thumbprint, null if the file isn't found or throw an exception.
    #

    param (
        [parameter(Mandatory = $true)][string] $CertificatePath,
        [parameter(Mandatory = $false)][string] $CertificatePassword
    )

    try {
        if (!(Test-Path $CertificatePath)) {
            return $null;
        }

        if ($CertificatePassword) {
            $sSecStrPassword = ConvertTo-SecureString -String $CertificatePassword -Force –AsPlainText
        }

        $certificateObject = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
        $certificateObject.Import($CertificatePath, $sSecStrPassword);

        return $certificateObject.Thumbprint
    } catch [Exception] {
        # 
        # Catch accounts already added.
        throw $_;
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到此错误:

Cannot find an …
Run Code Online (Sandbox Code Playgroud)

passwords powershell x509certificate2

9
推荐指数
3
解决办法
1万
查看次数

AngularFire2 在打字稿中获取经过身份验证的用户 ID

我正在尝试找出如何在 TypeScipt 中获取 Firebase Authenticated 用户的 uid:

<div> {{ (user | async)?.uid }} </div>
Run Code Online (Sandbox Code Playgroud)

我有以下 TS 代码:

import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app'

@Component({
  selector: 'app-user-portal',
  templateUrl: './user-portal.component.html',
  styleUrls: ['./user-portal.component.css']
})
export class UserPortalComponent implements OnInit {
  user: Observable<firebase.User>;

  constructor(
              public afAuth: AngularFireAuth
  ) {
    this.user = afAuth.authState;
  }

  ngOnInit() {

  }
}
Run Code Online (Sandbox Code Playgroud)

我读过的所有内容都表明我需要访问...的 id 属性

this.afAuth.auth.currentUser.uid
Run Code Online (Sandbox Code Playgroud)

......但这似乎没有暴露。如果我把它改成...

this.afAuth.auth.currentUser.toJSON()
Run Code Online (Sandbox Code Playgroud)

...并将其发送到控制台,然后我确实看到了一个 uid 属性。我怎样才能得到那个财产?

这甚至是为用户获取 uid 的正确方法吗?将...

this.afAuth.auth.currentUser.getIdToken()
Run Code Online (Sandbox Code Playgroud)

... 会更好?如果这样更好,我也看不出如何从中获取 uid。建议?

firebase typescript angularfire firebase-authentication angular

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

类型“PromiseLike&lt;any&gt;”上不存在属性“catch”

我有以下代码:

this.afDb.list('/demo').push({a: 'b'})
    .then(_ => console.log('works'))
    .catch(err => console.log('err: ', err));
Run Code Online (Sandbox Code Playgroud)

我在“捕获”上收到以下错误:

[ts] Property 'catch' does not exist on type 'PromiseLike<any>'.
Run Code Online (Sandbox Code Playgroud)

看起来像一个 AngularFire2 错误?

javascript firebase firebase-realtime-database angularfire2

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