如果证书本身未安装在工作站上但仅用于签署该特定文件,是否可以以某种方式以编程方式导出文件的数字证书主题?
我需要以某种方式从文件中提取该信息并检查它是否正确。最好使用Python/CMD/PowerShell
编辑:
抱歉缺少详细信息。
我目前正在使用这个 python 脚本(我修改为在 Python 3.6 上运行):http://www.zedwood.com/article/python-openssl-x509-parse-certificate来解析我从中提取的 .cer 文件我找到的带有这个小工具的原始可执行文件(我还对其进行了修改以与 Python 3 一起使用): https: //blog.didierstevens.com/programs/disitool/但只有在我将其从 DER 编码的二进制文件转换之后使用 Windows certutil 转换为 base-64。
不过,disitool 脚本的问题在于,它使用 pefile python 模块从可执行文件本身中剪切了一个“签名”字节数组,这使得提取的 .cer 文件无效,正如我在尝试执行操作时不断收到的 python 错误一样使用 OpenSSL.crypto 模块加载证书:
[('asn1 encoding routines', 'asn1_check_tlen', 'wrong tag'), ('asn1 encoding routines', 'asn1_item_embed_d2i', 'nested asn1 error'), ('asn1 encoding routines', 'asn1_template_noexp_d2i', 'nested asn1 error'), ('PEM routines', 'PEM_ASN1_read_bio', 'ASN1 lib')]
Run Code Online (Sandbox Code Playgroud)
但是解析一个好的提取证书(使用我上面发布的第一个脚本)是有效的,正如您在此处看到的:
所以,我想我只需要一种从可执行文件中提取证书的方法。或者,如果您发现我的解决方案太复杂,如果您知道如何从证书的主题字段中获取“Redmond”文本,我非常愿意接受想法:)
powershell python certificate command-line digital-signature
我有一个文本文件。每行包含一个字符串。有些字符串是重复的。我想删除重复的内容,但我想保留第一次出现的内容。例如:
line1
line1
line2
line3
line4
line3
line5
Run Code Online (Sandbox Code Playgroud)
应该
line1
line2
line3
line4
line5
Run Code Online (Sandbox Code Playgroud)
我尝试过:sort file1 | uniq -u > file2但这没有帮助。它删除了所有重复的字符串,而我希望出现第一个字符串。我不需要排序。只需删除新行中字符串的精确重复,同时保持其他所有内容不变即可。
我需要在办公室更改我的 Active Directory 密码,我们有关于 Linux 的文档以使用smbpasswd命令行。在 Debian 上,可以在 中找到此命令samba-common-bin。我希望可以从 MacOS 切换密码,但找不到smbpasswd命令。
docs.brew.sh 中的手动安装说明/usr/local非常简短且不能令人满意,如果我在不使用 的子目录中尝试它,则会导致一些错误sudo。这个问题中的方向及其接受的答案要好一些,但如果不使用 也无法工作sudo。
我知道我可能需要使用sudo来安装 Homebrew 本身,但希望我不需要继续使用sudo来安装新软件包、更新等(标准 Homebrew 安装脚本似乎使用,sudo但仅在绝对必要时使用,而标准结果是无需使用sudo来安装新包、更新等)
我应该如何手动将 Homebrew 安装到/usr/local子目录中?
手动安装 info/usr/local子目录的动机:
避免用户sudo安装后使用的动机:
Bind 使您能够更改版本、名称和主机名,如下所示:
options {
server-id none;
hostname none;
version "Domain Name Server";
};
Run Code Online (Sandbox Code Playgroud)
我想知道的是:如何从 Linux 命令行检查该信息?
我想在更改文件名的同时将文件从一个文件夹复制到另一个文件夹。我怎样才能做到这一点?
例如:使用此名称复制1.txt到: 。C:\new folder2.bat
默认情况下,iTerm 允许您按住 cmd 键单击文件名和 URL,以使用系统的默认应用程序打开它们。我希望能够更改它,以便将文件名添加到我当前正在输入的命令中。
\n\n这对于我的 git 流程很有用:git status\xe2\x86\x92 git add ...(此时我只想依次单击相关文件并将其附加)。
我想使用heredoc作为模板生成一些内容:
passphrase=$(<passphrase) envsubst <<EOF
apiVersion: v1
kind: Secret
metadata:
name: openshift-passphrase
stringData:
passphrase: ${passphrase}
EOF
Run Code Online (Sandbox Code Playgroud)
并将其通过管道传输到oc create -f -.
如果我在 后面添加管道EOF,则不起作用。
如何通过管道将带有变量替换的定界文档传递给消耗它的东西?
我正在使用批处理从 中提取信息adb devices -l,此命令显示如下消息:
123456789012345 device product:abc model:ABC device:abc transport_id:7
Run Code Online (Sandbox Code Playgroud)
我想从这个字符串中获取transport_id 7transport_id:7,所以我首先尝试按空格分割消息,效果很好。但是在尝试按冒号分割时,我收到一条错误消息“系统找不到文件transport_id:7”。我究竟做错了什么 ?
这是我的代码。
@ECHO off
for /f "tokens=1,2,3,4,5,6" %%a in ('adb.exe devices -l') do (
if "%%b" == "device" (
ECHO Serial Number : %%a
ECHO Transport Id : %%f
for /f "tokens=2 delims=:" %%A in ( %%f ) Do @Echo %%A
call test.bat %%A
)
)
PAUSE
Run Code Online (Sandbox Code Playgroud)
输出和错误:
Serial Number : 123456789012345
Transport Id : transport_id:7
The system cannot find …Run Code Online (Sandbox Code Playgroud) command-line ×10
linux ×3
batch ×2
macos ×2
terminal ×2
bash ×1
batch-file ×1
certificate ×1
dns ×1
git ×1
homebrew ×1
installation ×1
iterm ×1
iterm2 ×1
ldap ×1
passwords ×1
pipe ×1
powershell ×1
python ×1
rename ×1
samba ×1
sh ×1
shell ×1
ubuntu ×1
windows ×1