I have a number of TYPE RAW HTTP web services in SQL Anywhere 11, defined thusly:

CREATE SERVICE service_name TYPE 'RAW'
   AUTHORIZATION OFF USER user_name
   AS CALL procedure_name ( 
      :parameter1,  
      :parameter2 ); 

I would like to enable the use of HTTPS when connecting from a browser.

What do I have to code...

  • in the CREATE SERVICE statement,
  • on the dbsrv11 command line, and
  • in the browser URL?

Will I still be able to use HTTP by (for example) restarting the server with different parameters, without having to recompile the CREATE SERVICE?

asked 06 Sep '10, 13:48

Breck%20Carter's gravatar image

Breck Carter
26.2k430600865
accept rate: 20%


You must first add SECURE ON to your web service declaration to ensure that only HTTPS is used to access it. Without SECURE ON the web service can be used by both HTTP and HTTPS connections. E.g.

CREATE SERVICE service_name TYPE 'RAW'
   AUTHORIZATION OFF USER user_name SECURE ON
   AS CALL procedure_name ( 
      :parameter1,  
      :parameter2 ); 

You must also start the database server with the -xs HTTPS switch and specify a certificate using the identity and identity_password options. E.g.

dbsrv12 -xs https{Identity=certificate.id;Identity_Password=mypw} mydb.db

To use your web service from a browser, simply specify the HTTPS URL to the web service. E.g.

https://localhost/service_name

or, if you are running more than one database on your database server (and you did not specify the DBN option in the -xs https parameter), you will need to specify the database name in your URL. E.g.

https://localhost/mydb/service_name

If you started the server and gave a different port number (e.g. -xs https{port=1234,...etc...}) then you will need to give the port number in the browser URL. Note the default for HTTPS is 443. E.g. If port=1234 was specified, use:

https://localhost:1234/mydb/service_name

You can read more about this in the SA 12 documentation.

permanent link

answered 06 Sep '10, 15:38

Mark%20Culp's gravatar image

Mark Culp
23.2k9132272
accept rate: 40%

What if I omit SECURE ON, but start the engine with only -xs https? Will client browsers be able to use HTTP? I am hoping to be able to switch between http and https be only restarting the server, not making code changes (SECURE ON).

(07 Sep '10, 13:57) Breck Carter
2

Yes, if SECURE ON is omitted from the web service declaration and the server is started with -xs http{...},https{...} then the web service can be used from both HTTP and HTTPS connections. Without SECURE ON, if the server is started with -xs http{...} then the web service can be used from HTTP connections and if the server is started with -xs https{...} then the web service can be used from HTTPS connections. No web service definition changes are required.

(07 Sep '10, 15:41) Mark Culp
1

Once again, "Watcom Does Things The Way They Should Be Done"

(07 Sep '10, 22:42) Breck Carter
1

To summarize: If you have control over the dbsrv command line (i.e., you control whether the -xs option includes http or just specifies https) then NO SQL CHANGES are required to implement HTTPS. Just get a certificate and code the -xs option. Woohoo!

(21 Sep '10, 09:48) Breck Carter
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×21

question asked: 06 Sep '10, 13:48

question was seen: 919 times

last updated: 06 Sep '10, 15:38