小编Sea*_*ayn的帖子

BouncyCastle undefined length ASN1

I try to get a X509Certificate2 from a BountyCastle X509Certificate and a PKCS12. I use the following code:

 certificate = new X509Certificate2(rawData, password, storageFlags);
Run Code Online (Sandbox Code Playgroud)

I generate the rawData, like the following:

using (MemoryStream pfxData = new MemoryStream())
{
   X509CertificateEntry[] chain = new X509CertificateEntry[1];

   chain[0] = new X509CertificateEntry(x509);
   pkcsStore.SetKeyEntry(applicationName, new AsymmetricKeyEntry(subjectKeyPair.Private), chain);
   pkcsStore.Save(pfxData, passcode.ToCharArray(), random);
   var rawData = pfx.ToArray();
}
Run Code Online (Sandbox Code Playgroud)

The problem is, that I get the following exception:

在此输入图像描述

After some days of researching, I figured out, that the problem is …

c# mono x509 portable-class-library xamarin

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

不含参数的变量范围

例:

我有以下代码块:

if (!int.TryParse("123", out var parsedNumber))
{
    return;
}

Console.WriteLine(parsedNumber);
Run Code Online (Sandbox Code Playgroud)

控制台中的输出为:123

题:

生产线Console.WriteLine(parsedNumber);知道的可能性如何parsedNumber

根据我的理解,parsedNumber应该仅在中提供if-block,不是吗?

如果我尝试这样做:

foreach (var data in dataList)
{
   data += "something";
}

Console.WriteLine(data);
Run Code Online (Sandbox Code Playgroud)

Console.WriteLine(data);找不到data


我认为解决方案是out参数,但是我不确定。有人可以解释吗?

c# scope local-variables

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

在Linux Redhat/CentOS上为msodbcsql17安装unixODBC> = 2.3.1

我尝试使用CentOS/RedHat(Linux)在AWS EC2上安装msodbcsql17.

这些是我所遵循的步骤,来自Microsoft(LINK):

sudo su

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#RedHat Enterprise Server 6
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo

#RedHat Enterprise Server 7
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo

exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: …
Run Code Online (Sandbox Code Playgroud)

redhat centos unixodbc amazon-ec2 pyodbc

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