301 Moved Permanently

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
sbehera
Posts: 24
Joined: Tue Sep 07, 2021 10:46 pm

301 Moved Permanently

Post by sbehera »

Hello,
i am completely new to HTTPAPI (in general to HTTP concept) and to this forum. Could not find option to create new topic, so replying to this topic for help, please forgive me...

I just installed HTTPAPI to my iseries and just trying to use EXAMPLE1 provided as it is, to validate if my iseries does satisfy all requirements to make HTTP calls (have done basic checks like, Digital Certificate Manager and IBM HTTP server for i is installed). Running EXAMPLE1, getting error. Here is what i see in "httpapi_debug.txt", please help....

Log:

Code: Select all

HTTPAPI Ver 1.43 released 2021-04-19                                      
NTLM Ver 1.4.0 released 2014-12-22                                        
OS/400 Ver V7R1M0                                                         
                                                                          
New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0   
http_persist_open(): entered                                              
http_long_ParseURL(): entered                                             
DNS resolver retrans: 2                                                   
DNS resolver retry  : 2                                                   
DNS resolver options: x'00000136'                                         
DNS default domain: MYDOMANINAME                                        
DNS server found: My DNS Server IP                                           
DNS server found: My DNS Server IP                                            
Nagle's algorithm (TCP_NODELAY) disabled.                                   
Nagle's algorithm (TCP_NODELAY) disabled.                                   
http_persist_req(GET) entered.                                              
http_long_ParseURL(): entered                                               
http_long_ParseURL(): entered                                               
do_oper(GET): entered                                                       
There are 0 cookies in the cache                                            
GET /presentations/Web%20Services%20from%20RPG%20with%20HTTPAPI.pdf HTTP/1.1
Host: www.scottklement.com                                                  
User-Agent: http-api/1.43                                                   
recvresp(): entered                                              
HTTP/1.1 301 Moved Permanently                                   
Date: Tue, 07 Sep 2021 22:20:06 GMT                              
Server: Apache/2.4.48 (FreeBSD) OpenSSL/1.1.1k-freebsd PHP/7.4.21
Server: Apache/2.4.48 (FreeBSD) OpenSSL/1.1.1k-freebsd PHP/7.4.21               
Location: https://www.scottklement.com/presentations/Web%20Services%20from%20RPG
Content-Length: 299                                                             
Content-Type: text/html; charset=iso-8859-1                                     
                                                                                
                                                                                
SetError() #13: HTTP/1.1 301 Moved Permanently                                  
recvresp(): end with 301                                                        
recvdoc parms: identity 299                                                     
header_load_cookies() entered                                                   
recvdoc(): entered                                                              
SetError() #0:                                                                  
recvdoc(): Receiving 299 bytes.                                                 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved
SetError() #13: HTTP/1.1 301 Moved Permanently                                  
SetError() #13: HTTP/1.1 301 Moved Permanently
http_close(): entered
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: 301 Moved Permanently

Post by Scott Klement »

Hello sbehera,

To add a new topic, click on the forum name (in this case, "HTTPAPI") and then click "New Topic" at the top.
newtopic.png
newtopic.png (14.62 KiB) Viewed 16310 times
Since you already made your post I moved it to a new topic for you. Welcome to the forums!
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: 301 Moved Permanently

Post by Scott Klement »

Thanks for pointing this out. A few months ago, I updated my web site to use SSL to make it more secure. When I did that, I added code that redirects any requests made to non-SSL URLs so that they would now point to SSL URLs.

It didn't occur to me that some of the HTTPAPI EXAMPLE programs used non-SSL URLs. Oops!

In this case, it is sending back an HTTP 301 code (any of the 3xx codes mean that the site has moved) and is sending a new URL in the "Location" field. It looks like this:

Code: Select all

Location: https://www.scottklement.com/presentations/Web%20Services%20from%20RPG
So that is telling you that you are supposed to use that new URL, starting with https: (for SSL) instead of the old one starting with http:

However, since I realize not everyone has installed SSL on IBM i, I should probably enable the old non-encrypted URLs for the things that are in the examples. I'll look into that and respond later.
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: 301 Moved Permanently

Post by Scott Klement »

I changed this to allow non-SSL access, so EXAMPLE1 should now work again.
sbehera
Posts: 24
Joined: Tue Sep 07, 2021 10:46 pm

Re: 301 Moved Permanently

Post by sbehera »

Hello Scott,
thank you very much for your quick response. Yes it worked and pdf got downloaded to /tmp folder. Really happy to see all network level pre-requisite to go outside network is there in my system and there is no firewall related challenges.

Ultimately i am trying to make USPS API call to send from/to address information to USPS and in return receive shipping label from USPS server. Going through your documentation and USPS but because i am new to this whole concept it is little bit challenge so far.

Do you have any readymade program available that you can share with me to make USPS API call? Or from your examples/sample programs which one i can take as base line for the purpose i mentioned above?
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: 301 Moved Permanently

Post by Scott Klement »

Sorry, I don't have anything related to the USPS
sbehera
Posts: 24
Joined: Tue Sep 07, 2021 10:46 pm

Re: 301 Moved Permanently

Post by sbehera »

Hello,
i am using EXAMPLE14 (of HTTPAPI project by Scott) to do UPS package tracking getting error "GSKit) Key database file was not found". Full log is listed below. I am in OS7.1 and in system value QSSLPCL, *TLSV1.3 is not defined. I did try to add but system system does not allow. Is it because 7.1 does not support *TLSV1.3?In HTTPAPI_H, do see there are 6 parameters for 6 versions of TLS/SSL ad reading documentation all of them defaults to *ON but not able to find how to make peTLSv13 *OFF (if my OS does not support 1.3). Please help...

Log:
https_init(): entered
QSSLPCL = *TLSV1.2 *TLSV1.1 *TLSV1 *SSLV3
SSL version 2 support disabled
SSL version 3 support disabled
Old interface to TLS version 1.0 support enabled
TLS version 1.0 support enabled
TLS version 1.1 support enabled
TLS version 1.2 support enabled
Support for TLS 1.3 unavailable.
initializing GSK environment
(GSKit) Key database file was not found.
ssl_error(202): (GSKit) Key database file was not found.
SetError() #24: gsk_env_init: (GSKit) Key database file was not found.
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: 301 Moved Permanently

Post by Scott Klement »

You need to create the *SYSTEM certificate store (which is sometimes called a "key database") in the Digital Certificate Manager.

V7R1 has not been supported for a long time. This will work only if people you connect with still support very old (and not very secure) standards for TLS ("SSL").
sbehera
Posts: 24
Joined: Tue Sep 07, 2021 10:46 pm

Re: 301 Moved Permanently

Post by sbehera »

Hello Scott,
did confirm with UPS they do not need TLS 1.3 but TLS 1.2 is good for them.

Do see rpg COMMSSLR4 defaulting TLS1.3 parameter to *on (0933.00 D myTLSV13 s 1n inz(*on) ), i can change this to *off but how to make this change effective? Do i need to compile this but do not see a object in this name in LIBHTTP ?
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: 301 Moved Permanently

Post by Scott Klement »

If you are on V7R1, it doesn't matter how you set TLS 1.3, it will never work, the OS doesn't support it. The only reason you would disable TLS 1.3 is if you are on V7R3 or newer and wanted to make sure it was not used.

V7R1 only supports a few ciphers on TLS 1.1 or 1.2, which was a common source of frustration for people back when people still used V7R1. (Now you no longer hear this complaint, as nobody uses V7R1 anymore.)
Post Reply