将Mule Studio与Anypoint Enterprise Security模块配合使用。我遵循了mule文档,但我的加密步骤和解密步骤都进行了加密。我使用Kleopatra生成我的公共/私人证书。解密步骤的输出是双重加密文件。如果我去Kleopatra并解密它两次,我会得到原始的明文。
我有两个全局加密:配置元素,以防加密需要与解密不同
我想代码的显着部分是:
<encryption:decrypt config-ref="Decryption_PGP" doc:name="Decryption" using="PGP_ENCRYPTER" input-ref="#[message.payload]">
<encryption:pgp-encrypter principal="${pgp.principal}" />
</encryption:decrypt>
在示例中,我将一个明文文件放入$ {pgp.encryptIn}目录中,它应该对其进行加密,然后使用$ {pgp.decryptOut}目录中的明文解密它。我不明白为什么它的表现如此,并且可以肯定地使用新的眼睛和建议
谢谢,
- 唐
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:context="http://www.springframework.org/schema/context" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:encryption="http://www.mulesoft.org/schema/mule/encryption"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.mulesoft.org/schema/mule/encryption http://www.mulesoft.org/schema/mule/encryption/current/mule-encryption.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd"
>
<spring:beans>
<context:property-placeholder location="classpath:aaa_pgp.properties" />
</spring:beans>
<encryption:config name="Encryption_PGP" defaultEncrypter="PGP_ENCRYPTER" doc:name="Encryption_PGP">
<encryption:pgp-encrypter-config publicKeyRingFileName="${pgp.publicKeyRingFileName}"
secretKeyRingFileName="${pgp.secretKeyRingFileName}" secretAliasId="${pgp.secretAliasId}" secretPassphrase="${pgp.secretPassphrase}" />
</encryption:config>
<encryption:config name="Decryption_PGP" defaultEncrypter="PGP_ENCRYPTER" doc:name="Decryption_PGP">
<encryption:pgp-encrypter-config publicKeyRingFileName="${pgp.publicKeyRingFileName}"
secretKeyRingFileName="${pgp.secretKeyRingFileName}" secretAliasId="${pgp.secretAliasId}" secretPassphrase="${pgp.secretPassphrase}" />
</encryption:config>
<flow name="pgp_testEncryptFlow1" doc:name="pgp_testEncryptFlow1">
<file:inbound-endpoint path="${pgp.encryptIn}" moveToDirectory="${pgp.encryptIn.archive}"
moveToPattern="PlainSrc_#[function:datestamp:yyyyMMdd_HHmmss_SSS].dat" pollingFrequency="3000" fileAge="700" responseTimeout="10000"
doc:name="File" />
<encryption:encrypt config-ref="Encryption_PGP" doc:name="Encryption" using="PGP_ENCRYPTER" input-ref="#[message.payload]">
<encryption:pgp-encrypter principal="${pgp.principal}" />
</encryption:encrypt>
<file:outbound-endpoint path="${pgp.encryptOut}" outputPattern="Plain_#[function:datestamp:yyyyMMdd_HHmmss_SSS].txt"
responseTimeout="10000" doc:name="File" />
</flow>
<flow name="pgp_testDecryptFlow1" doc:name="pgp_testDecryptFlow1">
<file:inbound-endpoint path="${pgp.decryptIn}" moveToDirectory="${pgp.decryptIn.archive}"
moveToPattern="Encrypted_#[function:datestamp:yyyyMMdd_HHmmss_SSS].dat" pollingFrequency="3000" fileAge="700" responseTimeout="10000"
doc:name="File" />
<encryption:decrypt config-ref="Decryption_PGP" doc:name="Decryption" using="PGP_ENCRYPTER" input-ref="#[message.payload]">
<encryption:pgp-encrypter principal="${pgp.principal}" />
</encryption:decrypt>
<file:outbound-endpoint path="${pgp.decryptOut}" outputPattern="Decrypted_#[function:datestamp:yyyyMMdd_HHmmss_SSS].txt"
responseTimeout="10000" doc:name="File" />
</flow>
</mule>
我的属性文件如下:
# Common properties
pgp.decryptIn.archive=C:\\PGP\\In\\Processed
pgp.decryptIn=C:\\PGP\\In
pgp.decryptOut=C:\\PGP\\Out
pgp.encryptIn.archive=C:\\PGP\\PlainIn\\Processed
pgp.encryptIn=C:\\PGP\\PlainIn
pgp.encryptOut=${pgp.decryptIn}
pgp.principal=MuleTestPGP (ABCDEF) <blat@blat.com>
pgp.publicKeyRingFileName=C:\\PGP\\Keys\\MuleTestPublicPGP.gpg
pgp.secretAliasId=5557561372116423366
pgp.secretKeyRingFileName=C:\\PGP\\Keys\\MuleTestSecretPGP.gpg
pgp.secretPassphrase=Mule123456