mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Encrypt reports before sending them thru e-mail.
This commit is contained in:
@@ -30,14 +30,17 @@
|
||||
// Copyright © 2011-2018 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Hosting;
|
||||
using System.Web.Http;
|
||||
using System.Xml.Serialization;
|
||||
using Cinchoo.PGP;
|
||||
using DiscImageChef.CommonTypes.Metadata;
|
||||
using DiscImageChef.Server.Models;
|
||||
using MailKit.Net.Smtp;
|
||||
@@ -87,6 +90,15 @@ namespace DiscImageChef.Server.Controllers
|
||||
ctx.Reports.Add(new UploadedReport(reportV2));
|
||||
ctx.SaveChanges();
|
||||
|
||||
MemoryStream pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportV2String));
|
||||
MemoryStream pgpOut = new MemoryStream();
|
||||
ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt();
|
||||
pgp.Encrypt(pgpIn, pgpOut,
|
||||
Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
|
||||
"public.asc"), true);
|
||||
pgpOut.Position = 0;
|
||||
reportV2String = Encoding.UTF8.GetString(pgpOut.ToArray());
|
||||
|
||||
MimeMessage message = new MimeMessage
|
||||
{
|
||||
Subject = "New device report (old version)",
|
||||
@@ -143,6 +155,15 @@ namespace DiscImageChef.Server.Controllers
|
||||
ctx.Reports.Add(new UploadedReport(newReport));
|
||||
ctx.SaveChanges();
|
||||
|
||||
MemoryStream pgpIn = new MemoryStream(Encoding.UTF8.GetBytes(reportJson));
|
||||
MemoryStream pgpOut = new MemoryStream();
|
||||
ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt();
|
||||
pgp.Encrypt(pgpIn, pgpOut,
|
||||
Path.Combine(HostingEnvironment.MapPath("~") ?? throw new InvalidOperationException(),
|
||||
"public.asc"), true);
|
||||
pgpOut.Position = 0;
|
||||
reportJson = Encoding.UTF8.GetString(pgpOut.ToArray());
|
||||
|
||||
MimeMessage message = new MimeMessage
|
||||
{
|
||||
Subject = "New device report", Body = new TextPart("plain") {Text = reportJson}
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
<HintPath>..\packages\BouncyCastle.1.8.2\lib\BouncyCastle.Crypto.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ChoPGP, Version=1.0.1.2, Culture=neutral, PublicKeyToken=null">
|
||||
<HintPath>..\packages\ChoPGP.1.0.1.2\lib\ChoPGP.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net461" />
|
||||
<package id="BouncyCastle" version="1.8.2" targetFramework="net461" />
|
||||
<package id="ChoPGP" version="1.0.1.2" targetFramework="net461" />
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net461" />
|
||||
<package id="Google.Protobuf" version="3.5.1" targetFramework="net461" />
|
||||
<package id="Highsoft.Highcharts" version="6.2.0.67" targetFramework="net461" />
|
||||
|
||||
Reference in New Issue
Block a user