Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
encrypt example
$message
=
(
new
Email
(
)
)
->
date
(
new
\
DateTimeImmutable
(
'2019-04-07 10:36:30',
new
\
DateTimeZone
(
'Europe/Paris'
)
)
)
->
to
(
'fabien@symfony.com'
)
->
subject
(
'Testing'
)
->
from
(
'noreply@example.com'
)
->
text
(
'El Barto was not here'
)
;
$message
->
getHeaders
(
)
->
addIdHeader
(
'Message-ID', 'some@id'
)
;
$encrypter
=
new
SMimeEncrypter
(
$this
->samplesDir.'encrypt.crt'
)
;
$encryptedMessage
=
$encrypter
->
encrypt
(
$message
)
;
$this
->
assertMessageIsEncryptedProperly
(
$encryptedMessage
,
$message
)
;
}
public
function
testEncryptSignedMessage
(
)
{
$message
=
(
new
Email
(
)
)
->
date
(
new
\
DateTimeImmutable
(
'2019-04-07 10:36:30',
new
\
DateTimeZone
(
'Europe/Paris'
)
)
)
->
to
(
'fabien@symfony.com'
)
->
bcc
(
'luna@symfony.com'
)
->
subject
(
'Testing'
)
$message
=
(
new
Email
(
)
)
->
date
(
new
\
DateTimeImmutable
(
'2019-04-07 10:36:30',
new
\
DateTimeZone
(
'Europe/Paris'
)
)
)
->
to
(
'fabien@symfony.com'
)
->
subject
(
'Testing'
)
->
from
(
'noreply@example.com'
)
->
text
(
'El Barto was not here'
)
;
$message
->
getHeaders
(
)
->
addIdHeader
(
'Message-ID', 'some@id'
)
;
$encrypter
=
new
SMimeEncrypter
(
$this
->samplesDir.'encrypt.crt'
)
;
$encryptedMessage
=
$encrypter
->
encrypt
(
$message
)
;
$signer
=
new
SMimeSigner
(
$this
->samplesDir.'sign.crt',
$this
->samplesDir.'sign.key'
)
;
$signedMessage
=
$signer
->
sign
(
$encryptedMessage
)
;
$this
->
assertMessageSignatureIsValid
(
$signedMessage
,
$message
)
;
}
public
function
testSignedMessageWithPassphrase
(
)
{
$message
=
new
Message
(
(
new
Headers
(
)
)