certificate - 在 pentaho 上使用数字证书
解决方案
我也遇到过这个问题——而且很难弄清楚。因为 PDI 是一个 Java 应用程序,所以它不能很好地与操作系统的内置证书管理过程或忽略证书检查的选项配合使用。诀窍是使用将证书添加到 Java 密钥库keytool
我必须为 Windows 解决这个问题,所以这里有一个 PowerShell 脚本,但如果需要,你应该能够将这个想法应用于 shell。此外,Java certstore 的默认密码是“changeit”——这不是 type-o 或占位符。
Param (
[Parameter(
Mandatory = $False,
ValueFromPipeline = $False,
ValueFromPipelineByPropertyName = $False,
HelpMessage = 'Take action!')]
[switch]$doit
)
## Find the JRE folders
$jre_list = New-Object System.Collections.Generic.List[System.Object];
$program_folders = @('C:\Program Files\Java', 'C:\Program Files (x86)\Java');
ForEach ($folder in $program_folders) {
$jre_folders = Get-ChildItem -Path $folder -ErrorAction SilentlyContinue | Where-Object {$_.Name -like 'jre*'};
ForEach ($jre in $jre_folders) {
if ((Get-ChildItem -Path $($jre.FullName) -Recurse -Filter 'keytool.exe').Count -gt 0) {
$jre_list.Add($jre);
}
}
}
## Find the certificate files
$certroot = $PSScriptRoot;
$cert_files = Get-ChildItem -Path $certroot | Where-Object {$_.Name -match '^.+\.crt$' };
ForEach ($jre in $jre_list) {
Write-Host "`n == Found JRE @ $($jre.FullName)";
$keytool = "$($jre.FullName)\bin\keytool.exe";
$keystore = "$($jre.FullName)\lib\security\cacerts";
$cmd_list = "& '$keytool' -keystore '$keystore' -storepass changeit -list";
$existing_trusts = (Invoke-Expression -Command $cmd_list).Replace('\n', '\r\n');
ForEach ($cert in $cert_files) {
$file = "$certroot\$cert";
$alias = ($cert.Name).Replace('.crt', '');
Write-Host " >> $cert ($alias)";
ForEach ($item in $existing_trusts) {
$trust = $item.split(',')[0];
if ($trust -match $alias -or $trust -match '*.my.domain.com') {
if ($doit) {
## Remove existing entries
Write-Host " -- Removing entry for '$trust'";
$cmd_delete = ("& '$keytool' -keystore '$keystore' -storepass changeit -delete -alias $trust -noprompt").Replace("'", '"');
(Invoke-Expression -Command $cmd_delete -ErrorVariable stderr) 2>&1 | Out-Null
if (-Not $stderr) {
Write-Host ' Success';
}
Remove-Variable stderr -ErrorAction SilentlyContinue;
}
else {
Write-Host " ++ Existing entry in keystore: '$trust'";
}
}
}
if ($doit) {
## Add new entries
Write-Host " ++ Adding entry for '$alias'";
$cmd_add = ("& '$keytool' -keystore '$keystore' -storepass changeit -import -file '$file' -alias $alias -trustcacerts -noprompt").Replace("'", '"');
(Invoke-Expression -Command $cmd_add -ErrorVariable stderr) 2>&1 | Out-Null
if (-Not $stderr) {
Write-Host ' Success';
}
Remove-Variable stderr -ErrorAction SilentlyContinue;
}
}
Write-Host ' ';
}
推荐阅读
- java - 如何为战舰游戏编号网格阵列?
- javascript - 如何通过多次更新保存猫鼬模型
- xamarin - 如何将 Xamarin.Forms 共享项目迁移到 .NetStandard 项目
- java - 转换列表
- android - Kotlin 如何将 Long 转换为 Int?为超出范围的值获取不同的输出
- python-3.x - 如何在 while 循环中保持数据持久性,尤其是在将数据分配给函数中的变量时?
- reactjs - 我可以将 React.js 用于原生移动应用程序吗?
- html - 让可滚动的 Div Box 占据剩余高度
- c++ - 如何在rocksdb(make static_lib)期间修复这个编译错误?
- node.js - 如何在 graphql 查询中获取相关架构?