Safe Haskell | None |
---|---|
Language | Haskell2010 |
A library for DKIM (http://www.ietf.org/rfc/rfc6376.txt). Currently, only receiver side is implemented.
- runDKIM :: Resolver -> Mail -> IO DAResult
- runDKIM' :: Resolver -> Mail -> DKIM -> IO DAResult
- parseDKIM :: RawFieldValue -> Maybe DKIM
- data DKIM
- dkimDomain :: DKIM -> Domain
- dkimSelector :: DKIM -> ByteString
- dkimFieldKey :: CanonFieldKey
Documentation
Authentication with DKIM
runDKIM :: Resolver -> Mail -> IO DAResult Source #
Verifying Mail
with DKIM.
>>>
rs <- makeResolvSeed defaultResolvConf
>>>
:{
let lst = ["DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;" ," d=gmail.com; s=20161025;" ," h=mime-version:from:date:message-id:subject:to;" ," bh=IQB23UrpTWE7dPV0Ebeqy3ZJyCILT/tw2Ixhmh83FJ0=;" ," b=BCZrZwEnJfrdbbNqM+bWHeDrdHKvc6DvjafGCDndUUkHPbfVvvx2RTYfkC3LT1uCZC" ," 7vzKmucESLK5PVh4mAGNQjHDmdvhq7GIubOVK8Uoq+MpjZ321SwNI7rck/uLq512bfvO" ," NU9nYcUGNIKh+rho6V8XHX/REsfE+a8jGUvywZgV5IoORfTvejEluuy360PN0rAjSmi3" ," j5WRFV7XR5pCzAN78hmsUaTzf8zdwQwIlSsnUylnlRmc97xU5Ou3VBzxBV+ScXZsX5jI" ," TNv+ujuZcoO0fS0zm7UwmcOzXb01cQpBDqHK8cBvEdQ4+8LSx/Nf1UaOBrecw6GiwN23" ," BFBg==" ,"MIME-Version: 1.0" ,"Received: by 10.37.15.133 with HTTP; Wed, 20 Sep 2017 01:19:02 -0700 (PDT)" ,"From: Kazu Yamamoto <kazu.yamamoto@gmail.com>" ,"Date: Wed, 20 Sep 2017 17:19:02 +0900" ,"Message-ID: <CAKipW39GqeTzzQzB6WhM86_P==xTHwioa5gE=wZZ96fzf1j3Vw@mail.gmail.com>" ,"Subject: test for DKIM" ,"To: Kazu Yamamoto <kazu@iij.ad.jp>" ,"Content-Type: text/plain; charset=\"UTF-8\"" ,"" ,"this is test." ,"" ] mail = getMail $ BS8.intercalate "\r\n" lst in withResolver rs $ \rslv -> runDKIM rslv mail :} pass
runDKIM' :: Resolver -> Mail -> DKIM -> IO DAResult Source #
Verifying Mail
with DKIM. The value of DKIM-Signature:
should be parsed beforehand.
Parsing DKIM-Signature:
parseDKIM :: RawFieldValue -> Maybe DKIM Source #
Parsing DKIM-Signature:.
>>>
:{
let dkim = BS8.concat [ "v=1; a=rsa-sha256; s=brisbane; d=example.com;\n" , " c=relaxed/simple; q=dns/txt; i=joe@football.example.com;\n" , " h=Received : From : To : Subject : Date : Message-ID;\n" , " bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;\n" , " b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB\n" , " 4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHut\n" , " KVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV\n" , " 4bmp/YzhwvcubU4=;" ] in pPrintNoColor $ parseDKIM dkim :} Just ( DKIM { dkimVersion = "1" , dkimSigAlgo = RSA_SHA256 , dkimSignature = "AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHutKVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV4bmp/YzhwvcubU4=" , dkimBodyHash = "2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=" , dkimHeaderCanon = DKIM_RELAXED , dkimBodyCanon = DKIM_SIMPLE , dkimDomain0 = "example.com" , dkimFields = [ "received" , "from" , "to" , "subject" , "date" , "message-id" ] , dkimLength = Nothing , dkimSelector0 = "brisbane" } )
>>>
:{
let dkim = BS8.concat [ "v=1; a=rsa-sha256; s=brisbane; d=example.com;\n" , " q=dns/txt; i=joe@football.example.com;\n" , " h=Received : From : To : Subject : Date : Message-ID;\n" , " bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;\n" , " b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB\n" , " 4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHut\n" , " KVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV\n" , " 4bmp/YzhwvcubU4=;" ] in pPrintNoColor $ parseDKIM dkim :} Just ( DKIM { dkimVersion = "1" , dkimSigAlgo = RSA_SHA256 , dkimSignature = "AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHutKVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV4bmp/YzhwvcubU4=" , dkimBodyHash = "2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=" , dkimHeaderCanon = DKIM_SIMPLE , dkimBodyCanon = DKIM_SIMPLE , dkimDomain0 = "example.com" , dkimFields = [ "received" , "from" , "to" , "subject" , "date" , "message-id" ] , dkimLength = Nothing , dkimSelector0 = "brisbane" } )
dkimDomain :: DKIM -> Domain Source #
Getting of the value of the "d" tag in DKIM-Signature:.
dkimSelector :: DKIM -> ByteString Source #
Getting of the value of the "s" tag in DKIM-Signature:.
Field key for DKIM-Signature:
dkimFieldKey :: CanonFieldKey Source #
Canonicalized key for DKIM-Signature:.