它在 Windows 10 上工作正常,但当我尝试在 Windows Server 2012 上导入相同的 .pfx 文件时,它失败并显示消息“您输入的密码不正确”。
我使用 OpenSSL 3.0.0 创建证书、私钥和 .pfx 文件。我确信我使用了正确的密码。
有什么原因导致我无法在 Windows Server 2012 上导入 .pfx 文件吗?
当我打开解决方案资源管理器时,Visual Studio 会显示以下警告:
当我单击“管理 NuGet 包”链接并滚动浏览 nuget 包时,我看不到任何有关具体哪些包包含漏洞的指示。如何准确找出哪些软件包包含漏洞?
我正在学习 javascript 并尝试运行一些内联 javascript 代码。我正在使用电子快速入门指南,并且在尝试添加一些内联 JavaScript 之前代码运行良好。这是我的index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body>
<script>
console.log("Hello World"); // <-- this is the line causing problems
</script>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我尝试加载添加了console.log("Hello World")的网页时,出现错误:
拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script-src 'self'”。启用内联执行需要“unsafe-inline”关键字、哈希值(“sha256-m/hGOmrcpR2CLf5ZFUFQux1kBtD2znXvM4R5xVpagmI=”)或随机数(“nonce-...”)。
错误消息告诉我可以添加“不安全内联关键字”。我到底该怎么做呢?
我尝试过搜索示例,例如SO 上的示例或content-security-policy.com 上的指南。但所有示例都只是告诉我将“不安全内联”添加到内容安全策略中,而没有实际显示这是如何完成的。
我使用 .Net 6 和PInvoke nuget 包来访问 Win32 API,并通过以下方式创建 Win32 窗口:
IntPtr windowHandle = User32.CreateWindowEx(User32.WindowStylesEx.WS_EX_TOOLWINDOW,
"static",
"Window Title",
User32.WindowStyles.WS_OVERLAPPEDWINDOW |
User32.WindowStyles.WS_VISIBLE,
0,
0,
800,
800,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero);
Run Code Online (Sandbox Code Playgroud)
当窗口在屏幕上可见时,我的情况与此人相同窗口呈现良好,但对用户没有响应。当我将鼠标悬停在窗口上时,鼠标指针变为加载圆圈。
我认为无响应是由于窗口事件和消息未得到处理。我想以某种方式覆盖或挂钩 Win32 窗口的 WndProc 方法来处理消息,因为显然User32.GetMessage() 不会返回所有消息。
在 WPF 中,您可以向 HwndHost 添加一个挂钩来处理 WndProc 消息。如何在不使用 WPF 的情况下获取 .Net 6 中的 WndProc 消息?
我有以下最小示例代码:
struct MyStruct
{
long Size;
}
MyStruct myStruct;
bool result;
if (someCondition)
{
result = API.SomeThirdPartyCall(out myStruct); // the call will set 'result' to 'true' and assign a value to 'myStruct'
}
if (result)
{
result = API.AnotherCall(myStruct); // <-- gives error "Use of possibly unassigned field 'myStruct' (CS0170)"
}
Run Code Online (Sandbox Code Playgroud)
我知道myStruct当我尝试使用该结构进行第二次 API 调用时,它已被分配了一个值。该API是由第三方提供的,我无法更改它。有什么方法可以忽略我的字段可能未定义的错误吗?
我知道有一些类似的问题,例如How to check if a struct has been instanciated,但解决方案是使用可为空的结构,这对我来说不是一个选择,因为 API 不会接受可为空的结构。
c# ×2
.net-6.0 ×1
certificate ×1
html ×1
javascript ×1
openssl ×1
struct ×1
winapi ×1
wndproc ×1