Skip to content

C#类库中,Pingpp.cs下SetPrivateKeyPath的bug #6

@ZXYCir

Description

@ZXYCir

4.6中,由于安全性问题,这个方法会出现bug。
public static void SetPrivateKeyPath(string newPrivateKeyPath)
{
try
{
var privateKeyFile = new FileStream(newPrivateKeyPath, FileMode.Open);
PrivateKey = FormatPrivateKey((new StreamReader(privateKeyFile)).ReadToEnd());
privateKeyFile.Close();
}
catch (IOException ex)
{
throw new PingppException("Private key read error. " + ex);
}
}
请使用下面的安全方法:
public static void SetPrivateKeyPath(string newPrivateKeyPath)
{
try
{
var privateKeyFile = new FileStream(newPrivateKeyPath, FileMode.Open);
PrivateKey = FormatPrivateKey((new StreamReader(privateKeyFile)).ReadToEnd());
privateKeyFile.Close();
}
catch (IOException ex)
{
throw new PingppException("Private key read error. " + ex);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions