How to run WPF - XBAP as Full Trust Application(如何运行WPF -作为完全信任的应用XBAP)

XBAP
What is XBAP

XBAP (XAML Browser Application) is a new Windows technology used for creating Rich Internet Applications.

While windows applications are normally compiled to an .exe file, browser applications are compiled to an extension .xbap and can be run inside Internet Explorer.

Xbap applications are run within a security sandbox to prevent untrusted applications from controlling local system resources. (e.g  deleting local files)

Recently I work on WPF-XBAP application that will run from intranet website:

 xbap project type

This application must have unrestricted access to client's OS resources (that is unusual for XBAP projects ):

full trust app

I publish it on local website by using "Click-Once " deployment mechanism:

app publish

User can launch the application from deployment page (also can run application setup):

run app from website


I get security error ("User has refused to grant required permissions to the application"):

trust not granted


Means that application tried to perform some restricted action, beyond of XBAP sandbox. Actually it tried to read local video file:

xaml code

(It reads video file from local source, for preview option before uploading it to FTP server)

After some research I found how to fix that:


(1) Project must be signed with "Click-Once" manifest (security certificate file):

certificate

(If project doesn't contain "Test Certificate" click on rounded button to create a new one)

(2) After temporary certificate was created we'll save it into file (click on "More Details"):

save certificate 01


File export wizard (step A):

save certificate 02

File export wizard (step B):

save certificate 03

File export wizard (step C):
(Enter username and password, only if you did so while "Test Certificate" creation in par. 1)

save certificate 04

File export wizard (step D):

save certificate 05

File export wizard (step E):

save certificate 06

File export wizard (step F):

save certificate 07

(Now project certificate is saved as external file)

(3) Now we'll go to Internet Explorer and will register this certificate:
(Open "Internet Options" from "Tools" menu)

ie options

Click on "Certificates" in "Content" tab:

ie options - content tab

Import certificate file from "Trusted Root Certification Authorities" tab:

ie options - certificates

File import wizard (step A):

certificate import wizard 01

File import wizard (step B):

certificate import wizard 02

File import wizard (step C):

certificate import wizard 03

File import wizard (step D):

certificate import wizard 04

Confirm importing:

certificate import wizard 05

If succeed you'll get this window:

 certificate import wizard 06

And will see certificate here:

certificate imported - ok

Do same in "Trusted Publishers" tab:

ie options - certificates - publishers

Close IE options:

 ie options - ok


(6) No we'll go to "Signing" tab in project options and will select registered certificate:

app resign

Select registered certificate from local store:

certificate from store

(5) Republish the application:

app publish again

app publish again - msg

Now XBAP can run in "Full Trusted" mode:

xbap video player

Hope this post was helpful ;-)

How to run WPF-XBAP Application in Full-Trust Mode (Post #2: certificate extraction)

In previous post I wrote about running WPF-XBAP application on client machine in "Full-Trust Mode ".

clip_image002

That worked fine and the post was helpful (I know this from post's talk-backs).

I described how to generate security certificate and how to install it on client machine (thru IE options).

clip_image004

Recently, I worked with XBAP deployment files and required to copy them to new IIS server, during the process I've forgotten to include certificate (ext: "cer") file. I tried to open the application from client machine (in IE or Firefox) and got error message, that tells about security restrictions and that client has refused XBAP application in full-trust mode.

clip_image006

clip_image008

I know another way to generate certificate file without using MS Visual Studio and I'll show it here.

Some Introduction…

What are "deployment files"? – XBAP application BUILD generates assemblies and other resources that required running XBAP application. These files can be placed on IIS virtual folder and being downloaded to remote client machine by using supported Internet browser (IE or Firefox).

To see which files will be included in deployment folder go to "Publish" tab in project settings form and click on "Application Files":

clip_image010

To see options for deployment and how the setup page will look go to "Publish" tab in project settings form and click on "Options":

clip_image011

Check option: "Use '.deploy' file extension". - This is helpful for full-trust mode (some machines don't allow downloading assembly files like EXE and DLL):

clip_image013

If you want to include some additional files for application deployment, go to "Publish" tab in project settings form and click on "Prerequisites":

clip_image015

"Prerequisites" - setup-package files like .Net 2.*-3.* or Windows-Installer 3.* :

clip_image017

To generate deployment files and to publish them in selected folder click "Publish Now" in "Publish" tab in project settings form and click on "Prerequisites":

clip_image019

"Publish Now" generates these files:

clip_image021

"index.htm" is a deployment page, which was build with two options to run XBAP (Click-Once) application. "Run" option opens setup dialog (in case that application runs at first time or deployed with as new version), "launch" opens XBAP directly (without the installation process):

clip_image023

Usually I copy certificate file into this directory and place a link for download on "index.htm", but what can I do if I've forgotten to create the certificate file and already copied deployment files to client's IIS server and I don't have MS Visual Studio to create the new one from sources or event don’t have any sources (project code source files)? Answer: I can extract certificate into file from deployment executables. I can extract it from "setup.exe" file or from original "EXE" or "DLL" file if it wasn’t converted into other unknown file type.

I'll show ho to extract certificate from "setup.exe" (this file includes the same certificate as XBAP-Application EXE files).

1. Go to deployment folder and do right-click on "setup.exe" file:

clip_image025

2. Open "Properties" form and go to "Digital Signatures" tab page, select included digital signature and click on "Details":

clip_image027

3. Click "View Certificate" in "General" tab page:

clip_image029

4. Click on "Copy to File" in "Details" tab page:

clip_image031

5. Proceed with opened "Certificate Export Wizard":

(5.1)

clip_image033

(5.2)

clip_image035

(5.3) you can place extracted "cer" file in deployment folder for future use:

clip_image037

(5.4)

clip_image039

When you'll finish with wizard you'll get "cer" file:

clip_image041

See previous post with instructions that will help you with certificate installation. I found this post that also describes how to run XBAP in Full-Trust mode.

From: http://blogs.microsoft.co.il/blogs/maxim/archive/2008/03/05/wpf-xbap-as-full-trust-application.aspx

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值