首页 > 解决方案 > 在 pentaho 上使用数字证书

问题描述

我必须在我的转换上调用一个肥皂网络服务,但是当我尝试查找时,勺子会抛出以下消息

单击加载按钮时出错

我已经在我的机器上安装了数字证书,我有 .cer 存档。我不知道如何将这个证书放在我的转型中。

标签: certificatepentaho-spoonpentaho-data-integration

解决方案


我也遇到过这个问题——而且很难弄清楚。因为 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 ' ';
}

推荐阅读