Akavache icon indicating copy to clipboard operation
Akavache copied to clipboard

IEncryptionProvider ignored

Open AndAShape1 opened this issue 5 years ago • 4 comments

I've been using a custom encryption provider for over a year but now it's ignored. I have analysed my code and I cannot see BlobCache.Secure being used before this call...

Locator.CurrentMutable.Register(() => providerInstance, typeof(IEncryptionProvider));

I've managed to get it working using this...

var cache = BlobCache.Secure;

cache.GetType().GetField("_encryption", BindingFlags.NonPublic | BindingFlags.Instance)
   .SetValue(cache, providerInstance);

How is this happening? Given that Akavache doesn't set it back to the default (I've removed my call to Register), there must be a call to its static constructor somewhere prior. Could it be in Akavache's code?

AndAShape1 avatar Apr 30 '20 02:04 AndAShape1

Hey @FruitAndAShape :wave:,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.

https://opencollective.com/reactiveui

PS.: We offer priority support for all financial contributors. Don't forget to add priority label once you start contributing :smile:

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms!

Not sure. If you provide a sample repo one of us will have a look in about a week for you.

glennawatson avatar May 01 '20 02:05 glennawatson

I created a new blank forms app for iOS, then using Nuget I added Akavache 6.10.11 to both projects and this is my MainPage.xaml.cs file...

using System;
using Akavache;
using Akavache.Sqlite3;
using Splat;
using Xamarin.Forms;

namespace test
{
    public static class LinkerPreserve
    {
        static LinkerPreserve()
        {
            var persistentName = typeof(SQLitePersistentBlobCache).FullName;
            var encryptedName = typeof(SQLiteEncryptedBlobCache).FullName;
        }
    }

    public class e : IEncryptionProvider
    {
        public IObservable<byte[]> DecryptBlock(byte[] block) => throw new NotImplementedException();
        public IObservable<byte[]> EncryptBlock(byte[] block) => throw new NotImplementedException();
    }

    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();

            Locator.CurrentMutable.Register(() => new e(), typeof(IEncryptionProvider));

            var cache = BlobCache.Secure;
        }
    }
}

cache uses the default IEncryptionProvider.

AndAShape1 avatar May 01 '20 04:05 AndAShape1

Thanks. Will have a look through the week

glennawatson avatar May 01 '20 04:05 glennawatson