# In a CDF can I suppress or avoid “This file contains potentially unsafe dynamic content…”

I created a CDF to distribute to a single trusted user who both knows and trusts me and everything I make for them.

I downloaded the CDF player and the CDF to one of their computers. The CDF works great, except every time it runs the document displays the message:

This file contains potentially unsafe dynamic content..."

I've found some discussion about this at the old site: Why do I get security warning message..., but I don't see anything specific or useful in the link for CDF distribution.

The warning makes the user VERY NERVOUS and frankly appears slapdash and unprofessional. The blank gray field below it does nothing to inspire confidence. This makes for a very bad user experience.

When one launches an app or an application (created with anything else), presumably one has already vetted its provenance. Launch an application and one should see the application, not a disturbing warning. Lots of applications use "dynamic content". An application should just work. Sorry to get on a soap box here (well maybe not that sorry). It just seems that if Wolfram wants Mathematica to have the functionality to make real stand alone applications, then what we build should actually look like real applications.

Question 1: Can one suppress this unfortunate message programmatically from within the CDF document or its Manipulate[]?

When using Mathematica, one can place a notebook and probably a CDF in a trusted directory (see the above link), which avoids the display of this message. It just seems to defeat the purpose of a CDF and its great potential as a distribution platform to expect a user who does not have Mathematica to go to the trouble to figure out how to do that or even to have to do it.

Question 2: Can one even specify a trusted directory in the CDF Player?

Question 3: Does a CDF really need an installation program that would create a trusted directory and how could I do that?

Premiere support had no solution to this. I still have a little bit of hope that someone here might.

-
Related post Understanding CDF, especially point 6, listing some of the functionality that could issue the security warning, and the planned institute of trusted paths (nonexistent yet). –  István Zachar Jun 29 '12 at 16:37
As an enthusiastic user of CDF, I would like to echo jagra's complaint, and opine that the current treatment of security issues in CDF (need for fullscreen:'true' hack, gray box, frightening warning message, Enable Dynamics button, opaque rules for avoiding all this) may be a fatal blow for a technology that is trying to become a widespread standard for computable documents on the web. It is a pity. –  abwatson Jul 10 '12 at 20:17

## 4 Answers

As Phil has mentioned it will often be possible to change your code so that the warning isn't triggered in the first place. If possible, that would be the way to go, I think. If your code is too long or complex to change or it necessarily need one of the "unsafe" functions you would just need to tell the users to copy it to one of the directories that the CDF-Player trusts. I don't know whether that is documented, but a simple test showed that at least if you put the cdf to what the CDF-Player will show for $AddOnsDirectory no warning is shown. I would guess that$UserAddOnsDirectory would also work and probably some others of those that are part of the trusted directory path you know from Mathematica. There are corresponding directories defined also in the CDF-Player, but be aware that they are different from those that are defined in Mathematica.

If unsure what these directories are, you can create a CDF which shows them like this:

CDFDeploy[
FileNameJoin[{$HomeDirectory, "Desktop", "ShowTrustedDirectories.cdf"}], Button["Show Installation Directories", MessageDialog[Grid[{{ "$AddOnsDirectory", $AddOnsDirectory, }, { "$UserAddOnsDirectory", \$UserAddOnsDirectory
}}, Alignment -> Left], WindowSize -> Fit]
], WindowSize -> {500, 300}
]

If you open that cdf in the CDF-Player and press the button, it will show the corresponding directories for the computer/setup it is run on/with. You could also include such a Button with an additional explanation and "installation instruction" into the CDFs you give away...

-

Q1. You will note that the Wolfram CDF examples do not invoke this security warning when opened on computers. This is because they have been created with a higher level of signing (I think that is the terminology they use). So the answer is yes the message can be suppressed providing you have access to CDF Pro or whatever the thing is that can make these higher signing level CDFs.

Q2 and Q3 I think are redundant given the answer to Q1 (but stand corrected). With the base free product you get what you get. If you go Pro (or whatever the product is that overcomes these problems) the problems are not an issue.

-
Thanks for the input, but I do think that Q2 & Q3 remain open questions. Essentially does a work around exist? –  Jagra Jun 29 '12 at 12:37
My answer for Q2 and Q3 is an opinion rather than a categoric answer so I'd leave it open. –  Mike Honeychurch Jun 29 '12 at 12:42

In my case, I removed statements like Clear[] and it stopped this warning with dynamic CDFs. Unfortunately there is no magic list that I am aware of. Simplify the CDF to the bare minimum. Surprisingly, my CDF files use string conversions and piecewise functions with no problem at all regarding this unsafe dynamic content warning.

-

I tested a notebook that gives the same error message and found that if I deleted the grayed out cell where a graph had been displayed and closed the notebook, that when I reopened the notebook, the message did not pop up. A simple recalculation restored the graph.

-
I don't believe one can do that within a CDF –  Jagra Jun 29 '12 at 17:58
@Jagra, the first line of the last answer in the link in the OP, states the same thing as my answer. If the dynamic output is not present when the cdf is loaded, the message will not occur. So, clear that cell before deploying the document. –  Fred Kline Jun 29 '12 at 18:35
That does work in some cases, unfortunately in mine I want to at make the code itself hidden as much as possible from the user. See: mathematica.stackexchange.com/questions/7053/…. So what you suggest won't work for me. –  Jagra Jul 1 '12 at 23:38
This question is like the question at 5200. Mike Honeychurch's answer shows how to make the error message appear in the post so the user can run the notebook. The Notebook Security tutorial in Mathematica Help says that a notebook will produce the Unsafe Dynamics message if (among other things) it uses conversion between expressions and strings or options control (among others). That tutorial may give you a clue about your specific problem. –  SixWingedSeraph Jul 9 '12 at 20:55