几个小时前,我认为它是RSACryptoServiceProvider casting error。
但是我将调试器附加到Azure AppService网站,发现私钥有问题:
如果运行相同的证书,但是在localhost私钥下运行良好:
异常详细信息,当我尝试获取certificate.PrivateKey属性时:
<script>
import firebase from 'firebase'
export default {
name: 'Signup',
data: function() {
return {
email: '',
password: ''
}
},
methods: {
signUp: function() {
firebase.auth().createUserWithEmailAndPassword(this.email, this.password).then(
function(user) {
alert('Your account has been created!');
this.$store.userConnectedUpdate('true');
},
function(error) {
alert('Oops. ' + error.message)
}
);
}
}
}
</script>
当我尝试使用certificate.GetRSAPrivateKey()方法时:
System.Security.Cryptography.CryptographicException: Invalid provider type specified.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
我初始化证书的方式是这样的:
System.Security.Cryptography.CryptographicException: Invalid provider type specified.
at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()
at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate)
.Net版本框架为v4.7
所以我需要在Azure配置中进行配置吗? 有任何线索吗?
重复似乎是Azure限制,配置或类似的东西。