BTREE - C# Api, Can't encrypt database

Hi. I've a problem using berkeley api for C#. I'm trying to create an encrypted db.
That's an example of code I'm trying using:
BTreeDatabase btreeDB;
DatabaseEntry key ;
DatabaseEntry data;
public void dummy()
dbo.dbs = dbs;
String dbFileName = "Messaggi.db";
BTreeDatabaseConfig cfg = new BTreeDatabaseConfig();
DatabaseEnvironmentConfig dbCfg = new DatabaseEnvironmentConfig();
if (File.Exists(dbFileName))
MessageBox.Show("Elimino il database");
File.Delete(dbFileName);
try
cfg.Creation = CreatePolicy.ALWAYS;
cfg.Encrypted = true;//?? it's needed?
cfg.SetEncryption("123456789", EncryptionAlgorithm.DEFAULT);
btreeDB = BTreeDatabase.Open(dbFileName, cfg);
catch (BerkeleyDB.DatabaseException dbex)
Debug.WriteLine(dbex.StackTrace);
return;
but it throw that's exception:
Eccezione first-chance di tipo 'BerkeleyDB.DatabaseException' in libdb_dotnet53.dll
+'ExportMessages.vshost.exe' (Gestito (v4.0.30319)): caricato 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_it_b77a5c561934e089\mscorlib.resources.dll'+
in BerkeleyDB.DatabaseException.ThrowException(Int32 err) in D:\work\releases\db-5.3.21\lang\csharp\src\DatabaseException.cs:riga 72
in BerkeleyDB.Internal.DB.open(DB_TXN txn, String file, String database, DBTYPE type, UInt32 flags, Int32 mode) in D:\work\releases\db-5.3.21\lang\csharp\src\Internal\DB.cs:riga 261
in BerkeleyDB.BTreeDatabase.Open(String Filename, String DatabaseName, BTreeDatabaseConfig cfg, Transaction txn) in D:\work\releases\db-5.3.21\lang\csharp\src\BTreeDatabase.cs:riga 230
in BerkeleyDB.BTreeDatabase.Open(String Filename, BTreeDatabaseConfig cfg) in D:\work\releases\db-5.3.21\lang\csharp\src\BTreeDatabase.cs:riga 97
+in [...]+
It's my mistake?
Thank you.
Massimiliano.

Hi Massimiliano,
We had a bug related to encrypting database when using the C# API, bug #18891, but that was fixed in 5.2 (see the entry in the 5.2 change log)
+Fixed a bug where encryption could not be enabled for individual databases in an encrypted environment. [#18891]+
, hence the fix is part of Berkeley DB 5.3.21.
You haven't posted a complete stack trace or a small stand-alone testcase, so I cannot know exactly what is the problem.
But, here are the rules around using encryption:
A. When the database is part of an environment
- you will need to specify the encryption password and encryption algorithm using the DatabaseEnvironmentConfig.SetEncryption() method
- if you want a database in the environment to be encrypted (using the password and algorithm specified for the environment), you will need to set the DatabaseConfig.Encrypted property to true
- note that it is an error to try to set an encryption password/algorithm using the DatabaseConfig.SetEncryption() method for a database that is part of an environment, because the database will use the encryption password/algorithm specified for the environment
- here is a snippet of code showing how to correctly encrypt a database that is part of an environment:
     DatabaseEnvironmentConfig envCfg;
     envCfg = new DatabaseEnvironmentConfig();
     envCfg.Create = true;
     envCfg.UseMPool = true;
     envCfg.SetEncryption("123456789", EncryptionAlgorithm.DEFAULT);
     env = DatabaseEnvironment.Open(envHome, envCfg);
     BTreeDatabaseConfig btreeCfg = new BTreeDatabaseConfig();
     btreeCfg.Creation = CreatePolicy.IF_NEEDED;
     btreeCfg.Env = env;
     btreeCfg.Encrypted = true;
     db = BTreeDatabase.Open(dbName, btreeCfg);
     ...B. When the database is NOT part of an environment
     BTreeDatabaseConfig btreeCfg2 = new BTreeDatabaseConfig();
     btreeCfg2.Creation = CreatePolicy.IF_NEEDED;
     btreeCfg2.Encrypted = true;
     btreeCfg2.SetEncryption("123456789", EncryptionAlgorithm.DEFAULT);
     db2 = BTreeDatabase.Open(db2Name, btreeCfg2);This should clarify things. If not or you have additional questions let me know.
Regards,
Andrei

Similar Messages

  • Java Persistence API and creation of databases

    Hi All
    I have designed a small address book application which uses a database to store the information. I have used the new Java Persistence API to take care of my transactions and querrys with the database. This works great for one set database which is generated the first time the application runs and is used all the time.
    However I would like to make it so that the user can create a new address book (database) with a different name, I am not sure how I would do this using the Java Persistence API. I know the persistence.xml file must be placed in the META-INF directory of the source, so how would I be able manipulate the file or could I place the file somewhere else.
    David

    I am using the Derby database. I can create a database by passing the create command when I create the entity Manager like so:
    Connection c = DriverManager.getConnection("jdbc:derby:AddressBook;create=true", "app", "app");My problem is that as I understand it the persistence.xml file must know the name of the database. Unless there is another way of setting this. The line in the persistence file I am referring to is:
    <property name="toplink.jdbc.url" value="jdbc:derby:AddressBook"/>I wonder if I can progamatically set this value so that I have a default database in the persistence.xml and others can then create there own.
    David

  • SQLite encrypted Database does not get attached Using Adobe Air,Why?

    Hi,
    Any one knows the solution, am trying to attach the encrypted SQLite database adobe air-adobe flex bulder , it does not get attached using sqlconnection.attach throws error, though the given key is correct, but it gets open using sqlconnection.open with the same key, any one knows the solution, how to attach the encrypted data base, since am using two data base one is opened and another must be attached to the existing ,thanks in advance. using adobe air- flex related. i use the following code
                   databaseFile1 = File.applicationStorageDirectory.resolvePath("Sample_1.sqlite");
                   databaseFile2 = File.applicationStorageDirectory.resolvePath("Sample_2.sqlite");
    dbConnection.open(databaseFile1, SQLMode.CREATE, false, 1024, secKey);
    dbConnection.attach("db2",databaseFile2,null,secKey);
    got the following error.
    ERROR #3125 Unable to open the database file.

    And I would say more "this is the issue" !
    It should be possible as it is clearly stated in the doc :
    public function attach(name:String, reference:Object = null, responder:Responder = null, encryptionKey:ByteArray = null):void
    with 
    encryptionKey:ByteArray (default = null) — The encryption key for the database file. If the attach() call creates a database, the database is encrypted and the specified key is used as the encryption key for the database. If the call attaches an existing encrypted database, the value must match the database's encryption key or an error occurs. If the database being attached is not encrypted, or to create an unencrypted database, the value must be null (the default).
    so with a same encryptionkey, I (and this should be the same for FinalTarget) can open the encrypted db but not to attach it... quite strange.

  • Can I encrypt my procedures

    Hi friends,
    I am a new user of oracle. Is there a feature in oracle which enables me to encrypt my procedure. If so how can I achieve that.
    Thanks in advance
    Thanks
    Glady

    Is there a feature in oracle which enables me to encrypt my procedure.Why?
    Unless you have code that contains secrets (such as a decryption key), or have code running on a foreign system and want some form of IP right protection, encrypting your PL/SQL code makes very little sense.
    There have been quite a few posters here over the years, literally crying as they have encrypted their PL/SQL code in the database and lost the original copy of the code they had on disk. With encrypted code, you no longer can use the database as the container for the master or backup copy of that code.

  • Can I encrypt an indexed field?Why?

    Hi,everybody!
    Can I encrypt an indexed fields ?Why?
    lgs
    Edited by: user495600 on 2010-8-11 上午7:18

    Dear user495600,
    Please read the following articles;
    http://it.toolbox.com/wiki/index.php/How_to_encrypt_indexed_columns_in_Oracle
    http://www.oracle.com/technology/deploy/security/database-security/transparent-data-encryption/tde_faq.html#A12007
    From the Oracle documentation;
    Transparent Data Encryption
       1. Will encrypted data be decrypted for all users who have been authorized to see it?
       2. What is the overhead associated with TDE?
       3. What are the encryption algorithms that can be used with TDE?
       4. Is it possible to use 3rd party encryptions algorithms in place of the ones provided by TDE?
       5. Can I use TDE column encryption on columns used in foreign key constraints?
       6. Can columns that are used for joins be encrypted?
       7. Can indexed columns be encrypted?
       8. What data types and data lengths does TDE column encryption support?
       9. Does the data stay encrypted on the network?
      10. Does the database memory (SGA) contain clear-text or encrypted data?
      11. How do I know which data to encrypt?
      12. Where is the data that needs to be encrypted?
      13. With Oracle Database 11gR1, shall I use TDE column encryption or TDE tablespace encryption?
      14. How is TDE different from the encryption toolkit Oracle already provides?
      15. How is TDE licensed?
    Number 7:
    # Can indexed columns be encrypted?
    TDE tablespace encryption supports all indexes transparently.
    For TDE column encryption, the index needs to be a normal B-tree index, used for equality searches. In case of a composite, function-based index, the encrypted column cannot be the one that was used for the function. When encrypting a column with an existing index, it is recommended to first extract the index definition with dbms_metadata.get_ddl, then drop the index, encrypt the column with the 'no salt' option, and re-build the index.http://www.oracle.com/technology/obe/11gr1_db/security/tde/tde.htm
    Hope That Helps.
    Ogan

  • Encrypting Database settings

    Hello everyone,
    In a custome jsp/servlet led web-application, we either store the jdbc settings like database source, database name, username and password in a xml file or we specify them in the servlet itself.
    I want to know that what I should do or rather can do, to keep it (xml file) secret from everyone else so that no one other than me can know the db settings. Like, can we encrypt them or something like that, so that it is not visible even to other developers .. ??
    thanks

    You could create a library in the form of a JAR that you pass off to the other developers and let them just use it. But, really they could extract the JAR and decompile the classes to see the information. I would say give them a temporary username and password to the db and only allow them to see the data they need to see.
    Normally though, developers have access to the database. If they are to read and write to it you can't really hide data from them - minus using the JAR theory. And that's only if they don't care about seeing it. If they really want to get it, they can.
    Sensitive data should be stored in the production database while developers develop against a development database that has no sensitive data in it. That should solve any problems you have.

  • Help, How to encrypt database exp  backup files?

    Hi all,
    Now, My customer want to encrypt the database backup file. We use exp command backup database, and the backup files can be restored on other servers.
    So, How to encrypt database exp backup files?
    Thanks.
    Eric David.

    Hi;
    In addition to Aman post, please mention your db and OS version,so we can help you more specificly.
    I also suggest please see below googling which mention and explain rman+encrypted backup
    http://www.google.com.tr/#hl=tr&sa=X&ei=dCAtTpuwHMjOswa1gOH3Dw&ved=0CBUQBSgA&q=RMAN%2Bencrypted+backup&spell=1&fp=503f556dbe78c402&biw=1280&bih=797
    Regard
    Helios

  • While generating a crystal report can we edit database fiels in field explorer (at middle can we edit database fields)

    while generating a crystal report can we edit database fiels in field explorer (at middle can we edit database fields)

    Wrong forum to post the question, try to post the question in crystal reports community.
    Its not possible to edit the database fields while creating the reports, its only used to call the rows of values in it. Can you explain me in detail what are you actually looking for .
    --SumanT

  • While generating a crystal report can we edit database files in field explorer ?

    Hi,
    while generating a crystal report can we edit database files in field explorer (at middle can we edit database fields)
    Regards,
    Mahendra

    Wrong forum to post the question, try to post the question in crystal reports community.
    Its not possible to edit the database fields while creating the reports, its only used to call the rows of values in it. Can you explain me in detail what are you actually looking for .
    --SumanT

  • My Catalog - "Can't open Database" error

    After being able to open Photoshop Album Starter Edition successfully and without incident several months ago, one day I received this error:
    "Problem opening the Catalog named "My Catalog". Another user or application may have the catalog open, or one or more files may be missing, out of date, or damaged. [Microsoft] [ODBC Microsoft Access 97 Driver] can't open database 'unknown'. It may not be a database that your application recognizes or the file may be corrupt. Attempt to compact and recover this catalog then try again? - OK or Cancel"
    If I choose OK, then I get another error:
    "Catalog Recovery Incomplete - A problem was encountered during catalog recovery. Your catalog may be ok, but if you experience problems with it that can't be resolved through the Reover Catalog option or restarting your computer system you may need to restore this catalog from a backup. - OK"
    That goes to a 3rd error message:
    "Unable to open "My Catalog because it is damaged. Please choose: Open existing or Create a new catalog named My Catalog-1.psa"
    If I choose existing, it goes to the folder where My Catalog is stored, I can click it, and then I receive the first message. If I choose create a new catalog, it does, then gives me the first error message. PSA SE never opens, but the photo downloader appears in my Task bar Notification area, and I can Launch, Enable/Disable or Exit that program. If I try to acquire a photo, I end up with the same first error message.
    I've seen the other threads that address what may be close to this issue, and I've done all the fixes suggested, short of reinstalling WindowsXP, which I'd rather avoid, but I've had no luck - I still get the exact same error messages.
    I am using Office 97, including Access, Word, Excel, etc. but I'm not having any issues with those. I'm also using Pagemaker 7.0 and no issues there related to a catalog or database. I did have at one time a trial copy of Illustrator, and this problem started occurring after that trial was expired. I've since uninstalled Illustrator, done all the fixes suggested here, deleted the My Catalog files, restarted, uninstalled and re-installed PSA SE3.2, and still it cannot 'see' My Catalog.
    Any other suggestions (besides upgrading to Office-this decade, which I would love, but employer hasn't made that leap yet.)? TIA
    Tracey

    No, no multiple users on this machine, or on that application. Both are located on the C: drive of a computer with intranet and internet access.
    Could it have anything to do with the application Microsoft Access? [Microsoft ODBC Access97 driver] is named in the first error message. Access97 was always on this computer, but it wasn't actually put into use until about 6-8 months ago, and it was sometime after I started using it that I could no longer open PSA-SE. Connection? Fixable?

  • Can I encrypt a USB hard drive that's not for time machine?

    can I encrypt a USB hard drive that's not for time machine?

    Yes, if it has the GUID Partition Map Scheme, but only by erasing it and choosing a new format.
    See #2 in Using Disk Utility.

  • How can I encrypt my data links between switch uplink ports ? I'm unable to use "cts Manual" command in C3560X switch.suggest me

    How can I encrypt my data uplinks between switch trunk ports ? I'm unable to use "cts Manual" command in C3560X switch.suggest me as I want to encrypt my switch-to-switch link with Cisco TrustSec.

    Hi 
    Login to switch & go to interface..
    There you can give tags.. (ISL & DONT1Q)
    Command switch-port mode trunk
    Switch-port trunk encapsulation ssl or dot1Q

  • Can't create database from command prompt

    I am using Oracle 9i over Win XP. I can create new database using OEM wizard without any problem. However, when I try to create new database from command prompt, using following commands, I get an error.
    sqlplus /nolog
    connect / as internal (when I issue this I get message TNS no listener)
    CONNECT SYS/password AS SYSDBA (can't understand how to use this, I don't have password because I've not created the database)
    Can anyone help me how to create new database from command prompt?
    Thanx

    "TNS No Listener" => Start the listener
    To be connected as SYSDBA you dont need a password if your are logged in the DBA group, you just have to :
    PROD_:id
    uid=102(oracle) gid=103(oinstall)
    PROD_:sqlplus "/ as sysdba"
    SQL*Plus: Release 8.1.7.0.0 - Production on Wed Jul 23 11:46:50 2003
    (c) Copyright 2000 Oracle Corporation. All rights reserved.
    Connected to:
    Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
    With the Partitioning option
    JServer Release 8.1.7.4.0 - Production
    SQL> show user
    USER is "SYS"
    SQL>
    Fred

  • Which API can use to save PDF document with Adobe Reader 9?

    Hello,
        which API can use to save PDF document with Adobe Reader 9? It is said that "CosDocSaveWithParams" can't be used.
    thanks!
    jimmy

    Unless the PDF file is "READER ENABLED for SAVE" (see the adobe product pages on LiveCycle Reader extensions server)
    You are not able to call a Save at all, if the document is reader enabled then you need to use the JavaScript call to save the document,
    As you appear to be wanting to do this in a plug-in you would need to call the script from a plug-in, this can be done using the AFExecuteThisScript () function call.
    Please note that this does will fail if the document is not reader enabled for save and you need to include the Forms HFT in your plug-in,
    This plug-in would also have to be approved by Adobe to be used with the reader and as you are implementing a function that is available in the full Acrobat product this may not be a straight forward approval.
    HTH
    Malky

  • How can we handle database exceptions in bpel?

    Hi,
    I'm calling a couple of pl/sql based services in my bpel flow. Given the services are pl/sql based we might hit some databse errors . For example:
    -Existing State of Packages has been discarded
    -Database is down
    -PL/sql procedure itself throws an error etc
    I want to know how can any such database errors be handled gracefully? Can these be handled by a fault handler?If so, how?
    Thanks!

    You can use a catch/catchAll around the scope where these database related activities are happening. Within the Catch/CatchAll block, you can decide and provide the logic for a retrial or termination of the process or any other behaviour that you want.
    HTH
    Rahul

Maybe you are looking for